From 99dbbcfa3f8255a79004fbe8f9f212dd1856078c Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Fri, 7 Sep 2007 10:24:58 +0000 Subject: [PATCH] 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 --- src/Text2.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/Text2.cpp b/src/Text2.cpp index 62cff3ec03..b990703db8 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -162,15 +162,9 @@ Font Text::getFont(Buffer const & buffer, Paragraph const & par, Font f = par.getFontSettings(params, pos); if (!isMainText(buffer)) applyOuterFont(buffer, f); - Font lf; - Font rlf; - if (layout->labeltype == LABEL_MANUAL && pos < body_pos) { - lf = layout->labelfont; - rlf = layout->reslabelfont; - } else { - lf = layout->font; - rlf = layout->resfont; - } + bool lab = layout->labeltype == LABEL_MANUAL && pos < body_pos; + Font const & lf = lab ? layout->labelfont : layout->font; + Font rlf = lab ? layout->reslabelfont : layout->resfont; // In case the default family has been customized if (lf.family() == Font::INHERIT_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 - Font layoutfont; - if (pos < body_pos) - layoutfont = layout->labelfont; - else - layoutfont = layout->font; + Font const & layoutfont = pos < body_pos ? + layout->labelfont : layout->font; Font font = par.getFontSettings(params, pos); font.realize(layoutfont);