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

New commits:
commit 9a03308fafee8f424eba399c1aae56af02beafb0
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Aug 16 12:42:13 2019 +0200
Commit:     Noel Grandin <noel.gran...@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.gran...@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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to