The branch, breakrows, has been updated.

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

commit 8224ebef5e34b5997cc101c0a387414d49f55e81
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Tue Oct 5 15:52:31 2021 +0200

    Increase metrics cache maximal size
    
    Increase the maximal size of the breakString cache (to compute where
    to break lines) from 512kB to 10MB. This has a big impact of cache
    hits on large file like the example in #12297, which is now 99%. On
    this example the time taken by breakString decreases from 33.5us to
    2.4us.
    
    The string width cache has been increased fro 512kB to 1MB, but this
    does not make such a big difference.
    
    Additionally, comments and variable names have been improved.
    
    Related to bug #12297.

diff --git a/src/frontends/qt/GuiFontMetrics.cpp 
b/src/frontends/qt/GuiFontMetrics.cpp
index daddeae..1b460fc 100644
--- a/src/frontends/qt/GuiFontMetrics.cpp
+++ b/src/frontends/qt/GuiFontMetrics.cpp
@@ -77,25 +77,27 @@ namespace lyx {
 namespace frontend {
 
 
-/*
- * Limit (strwidth|breakstr)_cache_ size to 512kB of string data.
- * Limit qtextlayout_cache_ size to 500 elements (we do not know the
- * size of the QTextLayout objects anyway).
- * Note that all these numbers are arbitrary.
- * Also, setting size to 0 is tantamount to disabling the cache.
- */
-int cache_metrics_width_size = 1 << 19;
-int cache_metrics_breakstr_size = 1 << 19;
+namespace {
+// Maximal size/cost for various caches. See QCache documentation to
+// see what cost means.
+
+// Limit strwidth_cache_ total cost to 1MB of string data.
+int const strwidth_cache_max_cost = 1024 * 1024;
+// Limit breakat_cache_ total cost to 10MB of string data.
+// This is useful for documents with very large insets.
+int const breakstr_cache_max_cost = 10 * 1024 * 1024;
 // Qt 5.x already has its own caching of QTextLayout objects
 // but it does not seem to work well on MacOS X.
 #if (QT_VERSION < 0x050000) || defined(Q_OS_MAC)
-int cache_metrics_qtextlayout_size = 500;
+// Limit qtextlayout_cache_ size to 500 elements (we do not know the
+// size of the QTextLayout objects anyway).
+int const qtextlayout_cache_max_size = 500;
 #else
-int cache_metrics_qtextlayout_size = 0;
+// Disable the cache
+int const qtextlayout_cache_max_size = 0;
 #endif
 
 
-namespace {
 /**
  * Convert a UCS4 character into a QChar.
  * This is a hack (it does only make sense for the common part of the UCS4
@@ -119,9 +121,9 @@ inline QChar const ucs4_to_qchar(char_type const ucs4)
 
 GuiFontMetrics::GuiFontMetrics(QFont const & font)
        : font_(font), metrics_(font, 0),
-         strwidth_cache_(cache_metrics_width_size),
-         breakstr_cache_(cache_metrics_breakstr_size),
-         qtextlayout_cache_(cache_metrics_qtextlayout_size)
+         strwidth_cache_(strwidth_cache_max_cost),
+         breakstr_cache_(breakstr_cache_max_cost),
+         qtextlayout_cache_(qtextlayout_cache_max_size)
 {
        // Determine italic slope
        double const defaultSlope = tan(qDegreesToRadians(19.0));

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

Summary of changes:
 src/frontends/qt/GuiFontMetrics.cpp |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
Repository for new features
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to