mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-22 16:37:28 +00:00
Paragraph:
- constify some parameters - getFontSettings(): - getFirstFontSettings(): return a const ref instead of a copy. This brings a consistent 4% improvement in LateX generation. Might speedup rtl handling too. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26957 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d579893c5b
commit
6a8219c190
@ -915,7 +915,7 @@ void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwa
|
||||
DocIterator selbeg = cur.selectionBegin();
|
||||
|
||||
// Get font setting before we cut
|
||||
Font const font =
|
||||
Font const & font =
|
||||
selbeg.paragraph().getFontSettings(cur.buffer().params(), selbeg.pos());
|
||||
|
||||
// Insert the new string
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
/// specified by the latex macro \p ltx, to \p os starting from \p i.
|
||||
/// \return the number of characters written.
|
||||
int writeScriptChars(odocstream & os, docstring const & ltx,
|
||||
Change &, Encoding const &, pos_type & i);
|
||||
Change const &, Encoding const &, pos_type & i);
|
||||
|
||||
/// This could go to ParagraphParameters if we want to.
|
||||
int startTeXParParams(BufferParams const &, odocstream &, TexRow &,
|
||||
@ -135,9 +135,9 @@ public:
|
||||
///
|
||||
void latexSpecialChar(
|
||||
odocstream & os,
|
||||
OutputParams & runparams,
|
||||
Font & running_font,
|
||||
Change & running_change,
|
||||
OutputParams const & runparams,
|
||||
Font const & running_font,
|
||||
Change const & running_change,
|
||||
Layout const & style,
|
||||
pos_type & i,
|
||||
unsigned int & column);
|
||||
@ -146,20 +146,20 @@ public:
|
||||
bool latexSpecialT1(
|
||||
char_type const c,
|
||||
odocstream & os,
|
||||
pos_type & i,
|
||||
pos_type i,
|
||||
unsigned int & column);
|
||||
///
|
||||
bool latexSpecialTypewriter(
|
||||
char_type const c,
|
||||
odocstream & os,
|
||||
pos_type & i,
|
||||
pos_type i,
|
||||
unsigned int & column);
|
||||
///
|
||||
bool latexSpecialPhrase(
|
||||
odocstream & os,
|
||||
pos_type & i,
|
||||
unsigned int & column,
|
||||
OutputParams & runparams);
|
||||
OutputParams const & runparams);
|
||||
|
||||
///
|
||||
void validate(LaTeXFeatures & features,
|
||||
@ -603,7 +603,7 @@ bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
|
||||
|
||||
int Paragraph::Private::writeScriptChars(odocstream & os,
|
||||
docstring const & ltx,
|
||||
Change & runningChange,
|
||||
Change const & runningChange,
|
||||
Encoding const & encoding,
|
||||
pos_type & i)
|
||||
{
|
||||
@ -840,9 +840,9 @@ void Paragraph::Private::latexInset(
|
||||
|
||||
void Paragraph::Private::latexSpecialChar(
|
||||
odocstream & os,
|
||||
OutputParams & runparams,
|
||||
Font & running_font,
|
||||
Change & running_change,
|
||||
OutputParams const & runparams,
|
||||
Font const & running_font,
|
||||
Change const & running_change,
|
||||
Layout const & style,
|
||||
pos_type & i,
|
||||
unsigned int & column)
|
||||
@ -970,7 +970,7 @@ void Paragraph::Private::latexSpecialChar(
|
||||
|
||||
|
||||
bool Paragraph::Private::latexSpecialT1(char_type const c, odocstream & os,
|
||||
pos_type & i, unsigned int & column)
|
||||
pos_type i, unsigned int & column)
|
||||
{
|
||||
switch (c) {
|
||||
case '>':
|
||||
@ -998,7 +998,7 @@ bool Paragraph::Private::latexSpecialT1(char_type const c, odocstream & os,
|
||||
|
||||
|
||||
bool Paragraph::Private::latexSpecialTypewriter(char_type const c, odocstream & os,
|
||||
pos_type & i, unsigned int & column)
|
||||
pos_type i, unsigned int & column)
|
||||
{
|
||||
switch (c) {
|
||||
case '-':
|
||||
@ -1020,7 +1020,7 @@ bool Paragraph::Private::latexSpecialTypewriter(char_type const c, odocstream &
|
||||
|
||||
|
||||
bool Paragraph::Private::latexSpecialPhrase(odocstream & os, pos_type & i,
|
||||
unsigned int & column, OutputParams & runparams)
|
||||
unsigned int & column, OutputParams const & runparams)
|
||||
{
|
||||
// FIXME: if we have "LaTeX" with a font
|
||||
// change in the middle (before the 'T', then
|
||||
@ -1327,7 +1327,7 @@ void Paragraph::resetFonts(Font const & font)
|
||||
}
|
||||
|
||||
// Gets uninstantiated font setting at position.
|
||||
Font const Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
Font const & Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
pos_type pos) const
|
||||
{
|
||||
if (pos > size()) {
|
||||
@ -1342,7 +1342,16 @@ Font const Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
if (pos == size() && !empty())
|
||||
return getFontSettings(bparams, pos - 1);
|
||||
|
||||
return Font(inherit_font, getParLanguage(bparams));
|
||||
// Optimisation: avoid a full font instantiation if there is no
|
||||
// language change from previous call.
|
||||
static Font previous_font;
|
||||
static Language const * previous_lang = 0;
|
||||
Language const * lang = getParLanguage(bparams);
|
||||
if (lang != previous_lang) {
|
||||
previous_lang = lang;
|
||||
previous_font = Font(inherit_font, lang);
|
||||
}
|
||||
return previous_font;
|
||||
}
|
||||
|
||||
|
||||
@ -1373,12 +1382,21 @@ FontSpan Paragraph::fontSpan(pos_type pos) const
|
||||
|
||||
|
||||
// Gets uninstantiated font setting at position 0
|
||||
Font const Paragraph::getFirstFontSettings(BufferParams const & bparams) const
|
||||
Font const & Paragraph::getFirstFontSettings(BufferParams const & bparams) const
|
||||
{
|
||||
if (!empty() && !d->fontlist_.empty())
|
||||
return d->fontlist_.begin()->font();
|
||||
|
||||
return Font(inherit_font, bparams.language);
|
||||
// Optimisation: avoid a full font instantiation if there is no
|
||||
// language change from previous call.
|
||||
static Font previous_font;
|
||||
static Language const * previous_lang = 0;
|
||||
if (bparams.language != previous_lang) {
|
||||
previous_lang = bparams.language;
|
||||
previous_font = Font(inherit_font, bparams.language);
|
||||
}
|
||||
|
||||
return previous_font;
|
||||
}
|
||||
|
||||
|
||||
|
@ -253,10 +253,10 @@ public:
|
||||
between the characters font and the layoutfont.
|
||||
This is what is stored in the fonttable
|
||||
*/
|
||||
Font const
|
||||
Font const &
|
||||
getFontSettings(BufferParams const &, pos_type pos) const;
|
||||
///
|
||||
Font const getFirstFontSettings(BufferParams const &) const;
|
||||
Font const & getFirstFontSettings(BufferParams const &) const;
|
||||
|
||||
/** Get fully instantiated font. If pos == -1, use the layout
|
||||
font attached to this paragraph.
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "Session.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/FileNameList.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/Package.h"
|
||||
|
||||
@ -102,31 +103,23 @@ void LastFilesSection::setNumberOfLastFiles(unsigned int no)
|
||||
}
|
||||
|
||||
|
||||
void LastOpenedSection::read(istream & is)
|
||||
void LastOpenedSection::read(istream & /*is*/)
|
||||
{
|
||||
string tmp;
|
||||
do {
|
||||
char c = is.peek();
|
||||
if (c == '[')
|
||||
break;
|
||||
getline(is, tmp);
|
||||
FileName const file(tmp);
|
||||
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !file.isAbsolute())
|
||||
continue;
|
||||
|
||||
if (file.exists() && !file.isDirectory())
|
||||
lastopened.push_back(file);
|
||||
lastopened.clear();
|
||||
FileNameList list;// = theApp()->fileNameListFromSession("last_opened");
|
||||
for (size_t i = 0; i != list.size(); ++i) {
|
||||
FileName const & file = list[i];
|
||||
if (!file.isAbsolute() || !file.exists() || file.isDirectory())
|
||||
LYXERR(Debug::INIT, "Warning: invalid last opened file: " << file);
|
||||
else
|
||||
LYXERR(Debug::INIT, "LyX: Warning: Ignore last opened file: " << tmp);
|
||||
} while (is.good());
|
||||
lastopened.push_back(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LastOpenedSection::write(ostream & os) const
|
||||
void LastOpenedSection::write(ostream & /*os*/) const
|
||||
{
|
||||
os << '\n' << sec_lastopened << '\n';
|
||||
copy(lastopened.begin(), lastopened.end(),
|
||||
ostream_iterator<FileName>(os, "\n"));
|
||||
//theApp()->toSession(lastopened);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1541,11 +1541,11 @@ void Text::charsTranspose(Cursor & cur)
|
||||
|
||||
// Store the characters to be transposed (including font information).
|
||||
char_type char1 = par.getChar(pos1);
|
||||
Font const font1 =
|
||||
Font const & font1 =
|
||||
par.getFontSettings(cur.buffer().params(), pos1);
|
||||
|
||||
char_type char2 = par.getChar(pos2);
|
||||
Font const font2 =
|
||||
Font const & font2 =
|
||||
par.getFontSettings(cur.buffer().params(), pos2);
|
||||
|
||||
// And finally, we are ready to perform the transposition.
|
||||
|
@ -455,7 +455,7 @@ void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate
|
||||
bool rtl = false;
|
||||
if (cur.inTexted()) {
|
||||
Paragraph const & par = cur.paragraph();
|
||||
Font const font =
|
||||
Font const & font =
|
||||
par.getFontSettings(cur.bv().buffer().params(), cur.pos());
|
||||
rtl = font.isVisibleRightToLeft();
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ int replaceAll(BufferView * bv,
|
||||
cur.setCursor(doc_iterator_begin(buf.inset()));
|
||||
while (findForward(cur, match, false)) {
|
||||
pos_type pos = cur.pos();
|
||||
Font const font
|
||||
Font const & font
|
||||
= cur.paragraph().getFontSettings(buf.params(), pos);
|
||||
cur.recordUndo();
|
||||
int striked = ssize - cur.paragraph().eraseChars(pos, pos + ssize,
|
||||
|
@ -36,7 +36,7 @@ static bool moveItem(Paragraph & fromPar, pos_type fromPos,
|
||||
// Note: moveItem() does not honour change tracking!
|
||||
// Therefore, it should only be used for breaking and merging paragraphs
|
||||
|
||||
Font const tmpFont = fromPar.getFontSettings(params, fromPos);
|
||||
Font const & tmpFont = fromPar.getFontSettings(params, fromPos);
|
||||
Change const & tmpChange = fromPar.lookupChange(fromPos);
|
||||
|
||||
if (Inset * tmpInset = fromPar.getInset(fromPos)) {
|
||||
@ -123,7 +123,7 @@ void breakParagraph(BufferParams const & bparams,
|
||||
// breaking paragraph.
|
||||
if (tmp->empty()) {
|
||||
Font changed = tmp->getFirstFontSettings(bparams);
|
||||
Font old = par.getFontSettings(bparams, par.size());
|
||||
Font const & old = par.getFontSettings(bparams, par.size());
|
||||
changed.setLanguage(old.language());
|
||||
tmp->setFont(0, changed);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user