[Libreoffice-commits] core.git: sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Sep 17 20:44:00 UTC 2018


 sw/source/core/txtnode/fntcache.cxx |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 570f3c12fdb9db523cdef15c7a03cff82bd8ec15
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Mon Sep 17 17:39:50 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Mon Sep 17 22:43:39 2018 +0200

    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 at collabora.co.uk>
    Tested-by: Jenkins

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;
 };
 


More information about the Libreoffice-commits mailing list