font optimization: avoid one font copy in getFont

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@20123 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2007-09-07 10:24:58 +00:00
parent e622379109
commit 99dbbcfa3f

View File

@ -162,15 +162,9 @@ Font Text::getFont(Buffer const & buffer, Paragraph const & par,
Font f = par.getFontSettings(params, pos); Font f = par.getFontSettings(params, pos);
if (!isMainText(buffer)) if (!isMainText(buffer))
applyOuterFont(buffer, f); applyOuterFont(buffer, f);
Font lf; bool lab = layout->labeltype == LABEL_MANUAL && pos < body_pos;
Font rlf; Font const & lf = lab ? layout->labelfont : layout->font;
if (layout->labeltype == LABEL_MANUAL && pos < body_pos) { Font rlf = lab ? layout->reslabelfont : layout->resfont;
lf = layout->labelfont;
rlf = layout->reslabelfont;
} else {
lf = layout->font;
rlf = layout->resfont;
}
// In case the default family has been customized // In case the default family has been customized
if (lf.family() == Font::INHERIT_FAMILY) if (lf.family() == Font::INHERIT_FAMILY)
rlf.setFamily(params.getFont().family()); rlf.setFamily(params.getFont().family());
@ -178,11 +172,8 @@ Font Text::getFont(Buffer const & buffer, Paragraph const & par,
} }
// The uncommon case need not be optimized as much // The uncommon case need not be optimized as much
Font layoutfont; Font const & layoutfont = pos < body_pos ?
if (pos < body_pos) layout->labelfont : layout->font;
layoutfont = layout->labelfont;
else
layoutfont = layout->font;
Font font = par.getFontSettings(params, pos); Font font = par.getFontSettings(params, pos);
font.realize(layoutfont); font.realize(layoutfont);