mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
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.
This commit is contained in:
parent
5966d4fb8d
commit
572b06d640
@ -86,25 +86,27 @@ namespace lyx {
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
|
||||||
/*
|
namespace {
|
||||||
* Limit (strwidth|breakstr)_cache_ size to 512kB of string data.
|
// Maximal size/cost for various caches. See QCache documentation to
|
||||||
* Limit qtextlayout_cache_ size to 500 elements (we do not know the
|
// see what cost means.
|
||||||
* size of the QTextLayout objects anyway).
|
|
||||||
* Note that all these numbers are arbitrary.
|
// Limit strwidth_cache_ total cost to 1MB of string data.
|
||||||
* Also, setting size to 0 is tantamount to disabling the cache.
|
int const strwidth_cache_max_cost = 1024 * 1024;
|
||||||
*/
|
// Limit breakat_cache_ total cost to 10MB of string data.
|
||||||
int cache_metrics_width_size = 1 << 19;
|
// This is useful for documents with very large insets.
|
||||||
int cache_metrics_breakstr_size = 1 << 19;
|
int const breakstr_cache_max_cost = 10 * 1024 * 1024;
|
||||||
// Qt 5.x already has its own caching of QTextLayout objects
|
// Qt 5.x already has its own caching of QTextLayout objects
|
||||||
// but it does not seem to work well on MacOS X.
|
// but it does not seem to work well on MacOS X.
|
||||||
#if (QT_VERSION < 0x050000) || defined(Q_OS_MAC)
|
#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
|
#else
|
||||||
int cache_metrics_qtextlayout_size = 0;
|
// Disable the cache
|
||||||
|
int const qtextlayout_cache_max_size = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
/**
|
/**
|
||||||
* Convert a UCS4 character into a QChar.
|
* Convert a UCS4 character into a QChar.
|
||||||
* This is a hack (it does only make sense for the common part of the UCS4
|
* This is a hack (it does only make sense for the common part of the UCS4
|
||||||
@ -128,9 +130,9 @@ inline QChar const ucs4_to_qchar(char_type const ucs4)
|
|||||||
|
|
||||||
GuiFontMetrics::GuiFontMetrics(QFont const & font)
|
GuiFontMetrics::GuiFontMetrics(QFont const & font)
|
||||||
: font_(font), metrics_(font, 0),
|
: font_(font), metrics_(font, 0),
|
||||||
strwidth_cache_(cache_metrics_width_size),
|
strwidth_cache_(strwidth_cache_max_cost),
|
||||||
breakstr_cache_(cache_metrics_breakstr_size),
|
breakstr_cache_(breakstr_cache_max_cost),
|
||||||
qtextlayout_cache_(cache_metrics_qtextlayout_size)
|
qtextlayout_cache_(qtextlayout_cache_max_size)
|
||||||
{
|
{
|
||||||
// Determine italic slope
|
// Determine italic slope
|
||||||
double const defaultSlope = tan(qDegreesToRadians(19.0));
|
double const defaultSlope = tan(qDegreesToRadians(19.0));
|
||||||
|
Loading…
Reference in New Issue
Block a user