diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-19 12:29:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-09-20 10:33:24 +0200 |
commit | 77dec7588c9141b03f8ec0139eb96c298b26f261 (patch) | |
tree | d56625bf373e1966d57854a61168385c8a08e734 /cui/source/tabpages/autocdlg.cxx | |
parent | 3aff00ea2ff704547a4d9fa6e2bb2141eb57bf1d (diff) |
tdf#109158 improve sorting when loading large autocorrect file
reduces time from 2.0s to 1.7s
reduce work by
(*) reserving some arrays
(*) pre-sorting with a cheaper comparator
(*) don't copy when returning result, just return a const&
(*) flattening the data-structures to reduce pointer-chasing
Change-Id: I972bd7ffdbf2121c2d38c24aca9618ca708e920c
Reviewed-on: https://gerrit.libreoffice.org/79119
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui/source/tabpages/autocdlg.cxx')
-rw-r--r-- | cui/source/tabpages/autocdlg.cxx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index d2ab9b0013da..ca22e820f569 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -742,12 +742,14 @@ bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet* ) std::vector<SvxAutocorrWord> aDeleteWords; std::vector<SvxAutocorrWord> aNewWords; + aDeleteWords.reserve( rStringChangeList.aDeletedEntries.size() ); for (const DoubleString & deleteEntry : rStringChangeList.aDeletedEntries) { SvxAutocorrWord aDeleteWord( deleteEntry.sShort, deleteEntry.sLong ); aDeleteWords.push_back( aDeleteWord ); } + aNewWords.reserve( rStringChangeList.aNewEntries.size() ); for (const DoubleString & newEntry : rStringChangeList.aNewEntries) { //fdo#67697 if the user data is set then we want to retain the @@ -834,10 +836,10 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, { SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang); - SvxAutocorrWordList::Content aContent = pWordList->getSortedContent(); - m_xReplaceTLB->bulk_insert_for_each(aContent.size(), [this, &aContent](weld::TreeIter& rIter, int nIndex) { - auto const& elem = aContent[nIndex]; - bool bTextOnly = elem->IsTextOnly(); + const SvxAutocorrWordList::AutocorrWordSetType & rContent = pWordList->getSortedContent(); + m_xReplaceTLB->bulk_insert_for_each(rContent.size(), [this, rContent](weld::TreeIter& rIter, int nIndex) { + auto const& elem = rContent[nIndex]; + bool bTextOnly = elem.IsTextOnly(); // formatted text is only in Writer if (bSWriter || bTextOnly) { @@ -847,12 +849,12 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, OUString sId = OUString::number(reinterpret_cast<sal_Int64>(m_xTextOnlyCB.get())); m_xReplaceTLB->set_id(rIter, sId); } - m_xReplaceTLB->set_text(rIter, elem->GetShort(), 0); - m_xReplaceTLB->set_text(rIter, elem->GetLong(), 1); + m_xReplaceTLB->set_text(rIter, elem.GetShort(), 0); + m_xReplaceTLB->set_text(rIter, elem.GetLong(), 1); } else { - aFormatText.insert(elem->GetShort()); + aFormatText.insert(elem.GetShort()); } }, &m_aReplaceFixedWidths); m_xNewReplacePB->set_sensitive(false); |