The branch, str-metrics, has been updated.

- Log -----------------------------------------------------------------

commit 37494dfbccb8c0d9a66cedd059efc39903c44385
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Fri May 2 15:03:20 2014 +0200

    Speed-up drawing when text is not justified.
    
    Do not cut strings at separators in RowPainter when text is not
    justified. This speeds-up painting by reducing the number of strings
    to draw.
    
    Do also a modest cleanup of paintChar (remove dubious optimization).

diff --git a/00README_STR_METRICS_BRANCH b/00README_STR_METRICS_BRANCH
index e7a6f29..73f5ed3 100644
--- a/00README_STR_METRICS_BRANCH
+++ b/00README_STR_METRICS_BRANCH
@@ -40,16 +40,16 @@ What is done:
   useless workarounds which disable kerning and ligatures.
 
 * when lyxrc.force_paint_single_char is false, draw also RtL text
-  string-wise. This both speed-up drawing and prepare for code
+  string-wise. This both speeds-up drawing and prepares for code
   removal, since we now rely on Qt to do things we use to do by
   ourselves (see isArabic* and isHebrew* code in Encodings.cpp).
 
+* Do not cut strings at separators in RowPainter when text is not
+  justified. This speeds-up painting by reducing the number of strings
+  to draw.
 
-Next steps:
 
-* investigate whether strings could be cut at separators in RowPainter
-  only in justified text. This would speed-up painting in other cases
-  by lowering the number of strings to draw.
+Next steps:
 
 * get lots of testing.
 
diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp
index b0708bf..8286ec7 100644
--- a/src/rowpainter.cpp
+++ b/src/rowpainter.cpp
@@ -165,10 +165,9 @@ void RowPainter::paintChars(pos_type & vpos, Font const & 
font)
        // This method takes up 70% of time when typing
        pos_type pos = bidi_.vis2log(vpos);
        // first character
-       char_type prev_char = par_.getChar(pos);
-       vector<char_type> str;
+       char_type c = par_.getChar(pos);
+       docstring str;
        str.reserve(100);
-       str.push_back(prev_char);
 
        // special case for arabic
        string const & lang = font.language()->lang();
@@ -179,13 +178,12 @@ void RowPainter::paintChars(pos_type & vpos, Font const & 
font)
        // FIXME: Why only round brackets and why the difference to
        // Hebrew? See also Paragraph::getUChar
        if (swap_paren) {
-               char_type c = str[0];
                if (c == '(')
                        c = ')';
                else if (c == ')')
                        c = '(';
-               str[0] = c;
        }
+       str.push_back(c);
 
        pos_type const end = row_.endpos();
        FontSpan const font_span = par_.fontSpan(pos);
@@ -230,7 +228,8 @@ void RowPainter::paintChars(pos_type & vpos, Font const & 
font)
                if (c == '\t')
                        break;
 
-               if (!isPrintableNonspace(c))
+               if (!isPrintableNonspace(c)
+                   && (c != ' ' || row_.separator > 0))
                        break;
 
                // FIXME: Why only round brackets and why the difference to
@@ -243,13 +242,10 @@ void RowPainter::paintChars(pos_type & vpos, Font const & 
font)
                }
 
                str.push_back(c);
-               prev_char = c;
        }
 
-       docstring s(&str[0], str.size());
-
-       if (s[0] == '\t')
-               s.replace(0,1,from_ascii("    "));
+       if (str[0] == '\t')
+               str.replace(0,1,from_ascii("    "));
 
        /* Because we do our own bidi, at this point the strings are
         * already in visual order. However, Qt also applies its own
@@ -267,13 +263,13 @@ void RowPainter::paintChars(pos_type & vpos, Font const & 
font)
        // Pop directional formatting: return to previous state
        char_type const PDF = 0x202C;
        if (font.isVisibleRightToLeft()) {
-               reverse(s.begin(), s.end());
-               s = RLO + s + PDF;
+               reverse(str.begin(), str.end());
+               str = RLO + str + PDF;
        } else
-               s = LRO + s + PDF;
+               str = LRO + str + PDF;
 
        if (!selection && !change_running.changed()) {
-               x_ += pi_.pain.text(int(x_), yo_, s, font.fontInfo());
+               x_ += pi_.pain.text(int(x_), yo_, str, font.fontInfo());
                return;
        }
 
@@ -283,7 +279,7 @@ void RowPainter::paintChars(pos_type & vpos, Font const & 
font)
        else if (selection)
                copy.setPaintColor(Color_selectiontext);
 
-       x_ += pi_.pain.text(int(x_), yo_, s, copy);
+       x_ += pi_.pain.text(int(x_), yo_, str, copy);
 }
 
 

-----------------------------------------------------------------------

Summary of changes:
 00README_STR_METRICS_BRANCH |   10 +++++-----
 src/rowpainter.cpp          |   28 ++++++++++++----------------
 2 files changed, 17 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
Repository for new features

Reply via email to