<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - XLSX: LibreOffice is freezed when I try open Style list in Sidebar"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=126663#c5">Comment # 5</a>
on <a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - XLSX: LibreOffice is freezed when I try open Style list in Sidebar"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=126663">bug 126663</a>
from <span class="vcard"><a class="email" href="mailto:serval2412@yahoo.fr" title="Julien Nabet <serval2412@yahoo.fr>"> <span class="fn">Julien Nabet</span></a>
</span></b>
<pre>This part seems fishy:
<a href="https://opengrok.libreoffice.org/xref/core/sfx2/source/dialog/templdlg.cxx?r=45839115#1185">https://opengrok.libreoffice.org/xref/core/sfx2/source/dialog/templdlg.cxx?r=45839115#1185</a>
1185 while( pStyle )
1186 {
1187 //Bubblesort
1188 size_t nPos;
1189 for(nPos = aStrings.size(); nPos &&
aSorter.compare(aStrings[nPos-1], pStyle->GetName()) > 0; --nPos)
1190 {};
1191 aStrings.insert(aStrings.begin() + nPos, pStyle->GetName());
1192 pStyle = pStyleSheetPool->Next();
1193 }
Wouldn't it be better to push_back every pStyle names in aStrings with the
loop, then sort once afterwards with std::sort ?
Eg:
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;
+ });</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>