]> git.lyx.org Git - features.git/commitdiff
Only compute string length every 30 characters
authorJean-Marc <lasgouttes@lyx.org>
Mon, 20 Jul 2015 22:14:39 +0000 (00:14 +0200)
committerJean-Marc <lasgouttes@lyx.org>
Mon, 20 Jul 2015 22:20:42 +0000 (00:20 +0200)
This makes paragraph rebreaking muh much faster, at least on my ancient iMac Core 2 Duo.

src/Row.cpp

index ec01d5c465e6c526a0497508244adaf0ec208665..1bd11c97cd41aacb9749e603bc6c88991cc395cb 100644 (file)
@@ -333,11 +333,16 @@ void Row::add(pos_type const pos, char_type const c,
                Element e(STRING, pos, f, ch);
                elements_.push_back(e);
        }
-       dim_.wid -= back().dim.wid;
-       back().str += c;
-       back().endpos = pos + 1;
-       back().dim.wid = theFontMetrics(back().font).width(back().str);
-       dim_.wid += back().dim.wid;
+       if (back().str.length() % 30 == 0) {
+               dim_.wid -= back().dim.wid;
+               back().str += c;
+               back().endpos = pos + 1;
+               back().dim.wid = theFontMetrics(back().font).width(back().str);
+               dim_.wid += back().dim.wid;
+       } else {
+               back().str += c;
+               back().endpos = pos + 1;
+       }
 }