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

Julien Nabet (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 5 19:29:39 UTC 2019


 sfx2/source/dialog/templdlg.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 86ab2b2fcd95c6d14d0fd91dd1adaee5e7fd5713
Author:     Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Mon Aug 5 18:26:31 2019 +0200
Commit:     Julien Nabet <serval2412 at yahoo.fr>
CommitDate: Mon Aug 5 21:28:43 2019 +0200

    tdf#126663: optimize style list display in sidebar
    
    See Flamegraph perf:
    https://bugs.documentfoundation.org/attachment.cgi?id=153129
    
    + according to Xisco, time takes 15s instead of 145s
    (See https://bugs.documentfoundation.org/show_bug.cgi?id=126663#c7
    + https://bugs.documentfoundation.org/show_bug.cgi?id=126663#c8)
    
    Change-Id: Ib02bbd0793ec8e903359d5f59f7c33809028bb02
    Reviewed-on: https://gerrit.libreoffice.org/76988
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
    Tested-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 8cc0240f5f6f..c9e654afed45 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1184,13 +1184,13 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
 
     while( pStyle )
     {
-        //Bubblesort
-        size_t nPos;
-        for(nPos = aStrings.size(); nPos && aSorter.compare(aStrings[nPos-1], pStyle->GetName()) > 0; --nPos)
-        {};
-        aStrings.insert(aStrings.begin() + nPos, pStyle->GetName());
+        aStrings.push_back(pStyle->GetName());
         pStyle = pStyleSheetPool->Next();
     }
+    std::sort(aStrings.begin(), aStrings.end(),
+       [&aSorter](const OUString& rLHS, const OUString& rRHS) {
+       return aSorter.compare(rLHS, rRHS) < 0;
+       });
 
     size_t nCount = aStrings.size();
     size_t nPos = 0;


More information about the Libreoffice-commits mailing list