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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 16 12:39:20 UTC 2019


 sfx2/source/dialog/templdlg.cxx |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit 9a03308fafee8f424eba399c1aae56af02beafb0
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 16 12:42:13 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 16 14:38:38 2019 +0200

    tdf#126663 speed up styles display by sorting twice
    
    Change-Id: Ice5c2d0fd92196984efebf8c1183c1ed8399d1fb
    Reviewed-on: https://gerrit.libreoffice.org/77573
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index c9e654afed45..cf2de5311f0e 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1187,6 +1187,12 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
         aStrings.push_back(pStyle->GetName());
         pStyle = pStyleSheetPool->Next();
     }
+
+    // Paradoxically, with a list and non-Latin style names,
+    // sorting twice is faster than sorting once.
+    // The first sort has a cheap comparator, and gets the list into mostly-sorted order.
+    // Then the second sort needs to call its (much more expensive) comparator less often.
+    std::sort(aStrings.begin(), aStrings.end());
     std::sort(aStrings.begin(), aStrings.end(),
        [&aSorter](const OUString& rLHS, const OUString& rRHS) {
        return aSorter.compare(rLHS, rRHS) < 0;


More information about the Libreoffice-commits mailing list