diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-08-16 12:42:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-08-19 09:37:03 +0200 |
commit | 0789b179cea1c5fca3effc95bec169eeb5fd87cd (patch) | |
tree | 0f03e939c485229aa422d295e4ce47be70156cc3 | |
parent | 7eefb0ffb8d7bde110a76f000022c61f933663c4 (diff) |
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@collabora.co.uk>
(cherry picked from commit 9a03308fafee8f424eba399c1aae56af02beafb0)
Reviewed-on: https://gerrit.libreoffice.org/77698
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 55acfa1445d0..330255de5aa1 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; |