diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-09-17 17:39:50 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-09-17 22:43:39 +0200 |
commit | 570f3c12fdb9db523cdef15c7a03cff82bd8ec15 (patch) | |
tree | 998a94850871e6932ceed631d8a6f57973388053 | |
parent | 6a7ba34eb52ea919454b8f58a2d9de87229e6e83 (diff) |
tdf#119820 sw: optimize SwTextGlyphsKey comparison
Import time before:
12.192 seconds
After:
5.836 seconds (47.87% of baseline) for me.
Change-Id: Ifd650addaae3fe25b45cf0fd452f78372e60c467
Reviewed-on: https://gerrit.libreoffice.org/60591
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
-rw-r--r-- | sw/source/core/txtnode/fntcache.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 5f294fe6c7ca..bf98f097ec47 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -135,10 +135,6 @@ bool operator<(const SwTextGlyphsKey& l, const SwTextGlyphsKey& r) return true; if (l.m_pOutputDevice.get() > r.m_pOutputDevice.get()) return false; - if (l.m_aText < r.m_aText) - return true; - if (l.m_aText > r.m_aText) - return false; if (l.m_nIndex < r.m_nIndex) return true; if (l.m_nIndex > r.m_nIndex) @@ -147,6 +143,15 @@ bool operator<(const SwTextGlyphsKey& l, const SwTextGlyphsKey& r) return true; 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); + if (nRet < 0) + return true; + if (nRet > 0) + return false; + return false; }; |