sw/source/core/txtnode/thints.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
New commits: commit c6883e7a031dec5fe3a365c4fd6adccff09696e5 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Aug 25 09:20:49 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 25 10:47:17 2021 +0200 tdf#64991 speed up loading large RTL documents takes load time from 3min49 to 2min59 for me Use std::vector<bool> for RsidOnlyAutoFormatFlagMap, we only add values to the end so it is easy to correctly size this; and std::vectior<bool> is way more cache-dense Change-Id: Ia607c6a4d80a49a25d487d9ddde5041c166e966c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121009 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 1b88a49b498d..995d82606dab 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -2620,7 +2620,7 @@ static MergeResult lcl_Compare_Attributes( int i, int j, const std::pair< PortionMap::iterator, PortionMap::iterator >& aRange1, const std::pair< PortionMap::iterator, PortionMap::iterator >& aRange2, - std::unordered_map<int, bool>& RsidOnlyAutoFormatFlagMap); + std::vector<bool>& RsidOnlyAutoFormatFlagMap); bool SwpHints::MergePortions( SwTextNode& rNode ) { @@ -2632,9 +2632,10 @@ bool SwpHints::MergePortions( SwTextNode& rNode ) bool bRet = false; PortionMap aPortionMap; - std::unordered_map<int, bool> RsidOnlyAutoFormatFlagMap; + std::vector<bool> RsidOnlyAutoFormatFlagMap; + RsidOnlyAutoFormatFlagMap.resize(Count() + 1); sal_Int32 nLastPorStart = COMPLETE_STRING; - int nKey = 0; + sal_Int32 nKey = 0; // get portions by start position: for ( size_t i = 0; i < Count(); ++i ) @@ -2784,15 +2785,15 @@ static MergeResult lcl_Compare_Attributes( int i, int j, const std::pair< PortionMap::iterator, PortionMap::iterator >& aRange1, const std::pair< PortionMap::iterator, PortionMap::iterator >& aRange2, - std::unordered_map<int, bool>& RsidOnlyAutoFormatFlagMap) + std::vector<bool>& RsidOnlyAutoFormatFlagMap) { PortionMap::iterator aIter1 = aRange1.first; PortionMap::iterator aIter2 = aRange2.first; size_t const nAttributesInPor1 = std::distance(aRange1.first, aRange1.second); size_t const nAttributesInPor2 = std::distance(aRange2.first, aRange2.second); - bool const isRsidOnlyAutoFormat1(RsidOnlyAutoFormatFlagMap[i]); - bool const isRsidOnlyAutoFormat2(RsidOnlyAutoFormatFlagMap[j]); + bool const isRsidOnlyAutoFormat1 = i < sal_Int32(RsidOnlyAutoFormatFlagMap.size()) && RsidOnlyAutoFormatFlagMap[i]; + bool const isRsidOnlyAutoFormat2 = j < sal_Int32(RsidOnlyAutoFormatFlagMap.size()) && RsidOnlyAutoFormatFlagMap[j]; // if both have one they could be equal, but not if only one has it bool const bSkipRsidOnlyAutoFormat(nAttributesInPor1 != nAttributesInPor2);