Kaydet (Commit) a07bb28d authored tarafından Noel Grandin's avatar Noel Grandin

tdf#109269 very slow loading of user-defined dictionary word list

this is about 10x faster for me

Change-Id: I1d308c78dbdd04beaa432b546ba3b89bd617d57e
Reviewed-on: https://gerrit.libreoffice.org/56378
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst dbfa1c45
......@@ -460,10 +460,8 @@ void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId )
EnterWait();
OUString aStr;
pWordED->SetText(aStr);
pReplaceED->SetText(aStr);
pWordED->SetText(OUString());
pReplaceED->SetText(OUString());
bool bIsNegative = xDic->getDictionaryType() != DictionaryType_POSITIVE;
bool bLangNone = LanguageTag(
......@@ -517,17 +515,34 @@ void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId )
Sequence< Reference< XDictionaryEntry > > aEntries( xDic->getEntries() );
const Reference< XDictionaryEntry > *pEntry = aEntries.getConstArray();
sal_Int32 nCount = aEntries.getLength();
std::vector<OUString> aSortedDicEntries;
aSortedDicEntries.reserve(nCount);
for (sal_Int32 i = 0; i < nCount; i++)
{
aStr = pEntry[i]->getDictionaryWord();
sal_uLong nPos = GetLBInsertPos( aStr );
OUString aStr = pEntry[i]->getDictionaryWord();
if(!pEntry[i]->getReplacementText().isEmpty())
{
aStr += "\t" + pEntry[i]->getReplacementText();
}
pWordsLB->InsertEntry(aStr, nullptr, false, nPos == TREELIST_ENTRY_NOTFOUND ? TREELIST_APPEND : nPos);
aSortedDicEntries.push_back(aStr);
}
IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
const CollatorWrapper* pCollator = aIntlWrapper.getCollator();
std::sort(aSortedDicEntries.begin(), aSortedDicEntries.end(),
[&] (OUString const & lhs, OUString const & rhs)
{
sal_Int32 nCmpRes = pCollator->
compareString( getNormDicEntry_Impl(lhs), getNormDicEntry_Impl( rhs ) );
return nCmpRes < 0;
});
pWordsLB->SetUpdateMode(false); // speed up insert
for (OUString const & rStr : aSortedDicEntries)
{
pWordsLB->InsertEntry(rStr, nullptr, false, TREELIST_APPEND);
}
pWordsLB->SetUpdateMode(false);
if (pWordsLB->GetEntryCount())
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment