summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source')
-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)