summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJonathan Clark <jonathan@libreoffice.org>2024-09-03 05:49:28 -0600
committerJonathan Clark <jonathan@libreoffice.org>2024-09-03 21:32:00 +0200
commit6594b279a926e497261a4e802a5e74d2f3b97369 (patch)
tree6e7dfceab146108c0613a693832500e13bb5adb5 /vcl
parent7d3251adf2e95768c9169b92c8b3366c95f71bfa (diff)
tdf#92064 sw: Improve large paragraph layout performance
This change includes the following scalability improvements for documents containing extremely large paragraphs: - Reduces the size of layout contexts to account for LF control chars. - Due to typical access patterns while laying out paragraphs, VCL was making O(n^2) calls to vcl::ScriptRun::next(). VCL now uses an existing global LRU cache for script runs, avoiding much of this overhead. Change-Id: Iee03938683c95776a817d4819fe9a43c65a7c3fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172801 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/CommonSalLayout.cxx9
1 files changed, 6 insertions, 3 deletions
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 0602ecca3fc8..a932dd54b16f 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -382,7 +382,7 @@ bool GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
const int nLength = rArgs.mrStr.getLength();
const sal_Unicode *pStr = rArgs.mrStr.getStr();
- std::optional<vcl::text::TextLayoutCache> oNewScriptRun;
+ std::shared_ptr<const vcl::text::TextLayoutCache> pNewScriptRun;
vcl::text::TextLayoutCache const* pTextLayout;
if (rArgs.m_pTextLayoutCache)
{
@@ -390,8 +390,11 @@ bool GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
}
else
{
- oNewScriptRun.emplace(pStr, rArgs.mnEndCharPos);
- pTextLayout = &*oNewScriptRun;
+ // tdf#92064, tdf#162663:
+ // Also use the global LRU cache for full string script runs.
+ // This obviates O(n^2) calls to vcl::ScriptRun::next() when laying out large paragraphs.
+ pNewScriptRun = vcl::text::TextLayoutCache::Create(rArgs.mrStr);
+ pTextLayout = pNewScriptRun.get();
}
// nBaseOffset is used to align vertical text to the center of rotated