diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-05-17 12:43:38 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-20 14:53:12 +0200 |
commit | 50588a1583e3cc5dc647a35889e50478c7bfd033 (patch) | |
tree | 460a6c4137c2ceade8132c760b79eac99dee4c81 /cui | |
parent | 092da974f180e6f166c2e5662ce11db72351700b (diff) |
Related: tdf#109158 GtkTreeStore append performance is poor
so prepend in opposite order
Change-Id: Ibfa2878d999b945e774b5a90309a663f11b132b5
Reviewed-on: https://gerrit.libreoffice.org/72488
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/tabpages/autocdlg.cxx | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 20042f986d47..861f2a70396f 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -801,67 +801,63 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, } } - m_xReplaceTLB->clear(); if( !bSWriter ) aFormatText.clear(); - m_xReplaceTLB->freeze(); - - if( aDoubleStringTable.find(eLang) != aDoubleStringTable.end() ) + if (aDoubleStringTable.find(eLang) != aDoubleStringTable.end()) { DoubleStringArray& rArray = aDoubleStringTable[eNewLanguage]; - for(DoubleString & rDouble : rArray) - { + + m_xReplaceTLB->bulk_insert_for_each(rArray.size(), [this, &rArray](weld::TreeIter& rIter, int nIndex) { + DoubleString &rDouble = rArray[nIndex]; bool bTextOnly = nullptr == rDouble.pUserData; // formatted text is only in Writer if (bSWriter || bTextOnly) { - OUString sId; if (!bTextOnly) { // that means: with format info or even with selection text - sId = OUString::number(reinterpret_cast<sal_Int64>(rDouble.pUserData)); + OUString sId = OUString::number(reinterpret_cast<sal_Int64>(rDouble.pUserData)); + m_xReplaceTLB->set_id(rIter, sId); } - m_xReplaceTLB->append(sId, rDouble.sShort); - m_xReplaceTLB->set_text(m_xReplaceTLB->n_children() - 1, rDouble.sLong, 1); + m_xReplaceTLB->set_text(rIter, rDouble.sShort, 0); + m_xReplaceTLB->set_text(rIter, rDouble.sLong, 1); } else { aFormatText.insert(rDouble.sShort); } - } + }); } else { SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang); SvxAutocorrWordList::Content aContent = pWordList->getSortedContent(); - for (auto const& elem : aContent) - { + m_xReplaceTLB->bulk_insert_for_each(aContent.size(), [this, &aContent](weld::TreeIter& rIter, int nIndex) { + auto const& elem = aContent[nIndex]; bool bTextOnly = elem->IsTextOnly(); // formatted text is only in Writer if (bSWriter || bTextOnly) { - OUString sId; if (!bTextOnly) { // that means: with format info or even with selection text - sId = OUString::number(reinterpret_cast<sal_Int64>(m_xTextOnlyCB.get())); + OUString sId = OUString::number(reinterpret_cast<sal_Int64>(m_xTextOnlyCB.get())); + m_xReplaceTLB->set_id(rIter, sId); } - m_xReplaceTLB->append(sId, elem->GetShort()); - m_xReplaceTLB->set_text(m_xReplaceTLB->n_children() - 1, elem->GetLong(), 1); + m_xReplaceTLB->set_text(rIter, elem->GetShort(), 0); + m_xReplaceTLB->set_text(rIter, elem->GetLong(), 1); } else { aFormatText.insert(elem->GetShort()); } - } + }); m_xNewReplacePB->set_sensitive(false); m_xDeleteReplacePB->set_sensitive(false); } - m_xReplaceTLB->thaw(); - SfxViewShell* pViewShell = SfxViewShell::Current(); if (pViewShell && pViewShell->HasSelection()) { |