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-23 10:55:51 +0200 |
commit | 36ea8194ae86a9072b2d8a1154ac5e8c83764fce (patch) | |
tree | a3757db1aee4ad08cb5410059f3b006091b94973 /cui | |
parent | tdf#127657: FIREBIRD error in query input param when referred field is integer (diff) | |
download | core-36ea8194ae86a9072b2d8a1154ac5e8c83764fce.tar.gz core-36ea8194ae86a9072b2d8a1154ac5e8c83764fce.zip |
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>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/79377
Diffstat (limited to 'cui')
-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 20028e16456b..6573e3b43e0b 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -743,12 +743,14 @@ bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet* ) std::vector<SvxAutocorrWord> aDeleteWords; std::vector<SvxAutocorrWord> aNewWords; + aDeleteWords.reserve( rStringChangeList.aDeletedEntries.size() ); for (DoubleString & deleteEntry : rStringChangeList.aDeletedEntries) { SvxAutocorrWord aDeleteWord( deleteEntry.sShort, deleteEntry.sLong ); aDeleteWords.push_back( aDeleteWord ); } + aNewWords.reserve( rStringChangeList.aNewEntries.size() ); for (DoubleString & newEntry : rStringChangeList.aNewEntries) { //fdo#67697 if the user data is set then we want to retain the @@ -835,10 +837,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) { @@ -848,12 +850,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); |