summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/fntcache.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-10-12 17:57:36 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-10-12 20:38:31 +0200
commitc7b83934fcf4120c1a4cba8e1eaf9c7aef9edc82 (patch)
treeb67ad5620329988102e4f02dd8a30ead4cd92aa9 /sw/source/core/txtnode/fntcache.cxx
parente30f6a8c6b053e7a7b9c54fb3fdaed4e73bb5389 (diff)
tdf#119992 sw: compare sub-strings in SwTextGlyphsKey comparison
Time till the layout reaches idle, before: 77.412 seconds After: 26.221 seconds (33% of baseline) for me. Change-Id: Idd0c5255070c836fde2fb048b02c851f5f2321e4 Reviewed-on: https://gerrit.libreoffice.org/61724 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'sw/source/core/txtnode/fntcache.cxx')
-rw-r--r--sw/source/core/txtnode/fntcache.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 740710c6c27e..9166965dfb7e 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -144,9 +144,16 @@ bool operator<(const SwTextGlyphsKey& l, const SwTextGlyphsKey& r)
if (l.m_nLength > r.m_nLength)
return false;
- // Comparing strings is expensive, so compare them only at the end, and
- // only once.
- sal_Int32 nRet = l.m_aText.compareTo(r.m_aText);
+ // Comparing strings is expensive, so compare them:
+ // - only at the end of this function
+ // - only once
+ // - only the relevant substring (if the index/length is not out of bounds)
+ sal_Int32 nRet = 0;
+ if (l.m_nLength < 0 || l.m_nIndex < 0 || l.m_nIndex + l.m_nLength > l.m_aText.getLength())
+ nRet = l.m_aText.compareTo(r.m_aText);
+ else
+ nRet = memcmp(l.m_aText.getStr() + l.m_nIndex, r.m_aText.getStr() + r.m_nIndex,
+ l.m_nLength * sizeof(sal_Unicode));
if (nRet < 0)
return true;
if (nRet > 0)