]> git.lyx.org Git - features.git/commitdiff
optimization: save some font copying
authorAlfredo Braunstein <abraunst@lyx.org>
Sun, 2 Sep 2007 23:37:11 +0000 (23:37 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Sun, 2 Sep 2007 23:37:11 +0000 (23:37 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20016 a592a061-630c-0410-9148-cb99ea01b6c8

src/TextMetrics.cpp

index c69ab1a345b2b9e645e400c692d9fd6d5f697a92..d4aaa9a52f8d0c1e6a4c445b2c6a9b54b3472215 100644 (file)
@@ -225,15 +225,11 @@ Font TextMetrics::getDisplayFont(pit_type pit, pos_type pos) const
                Font f = par.getFontSettings(params, pos);
                if (!text_->isMainText(buffer))
                        applyOuterFont(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());
@@ -241,11 +237,8 @@ Font TextMetrics::getDisplayFont(pit_type pit, pos_type pos) const
        }
 
        // 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);