From 1be12e6d298a1e22871cdb9eecb7b6440b0d1d88 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 20 Jun 2024 14:11:09 +0200 Subject: tdf#144208 speedup doc with lots of redline(13) Add a custom method to SfxItemSet, to avoid some of the function calling overhead in a hot loop Change-Id: I525c9a696af941c6e39aa1677eb2a85f69c621bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169271 Reviewed-by: Noel Grandin Tested-by: Jenkins --- svl/source/items/itemset.cxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'svl/source') diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 251194194d11..b3a6dd8f68cf 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -929,6 +929,31 @@ bool SfxItemSet::HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem) const return bRet; } +void SfxItemSet::CollectHasItems(std::vector& rItemWhichs) const +{ + for(auto const & rPair : m_aWhichRanges) + { + const sal_uInt16 nBeg = rPair.first; + const sal_uInt16 nEnd = rPair.second; + for( sal_uInt16 nWhich = nBeg; nWhich <= nEnd; ++nWhich ) + { + bool bHasItem = false; + auto aHit(m_aPoolItemMap.find(nWhich)); + if (aHit != m_aPoolItemMap.end()) + { + bHasItem = !IsInvalidItem(aHit->second) && !IsDisabledItem(aHit->second); + } + else + { + if (m_pParent) + bHasItem = SfxItemState::SET == m_pParent->GetItemState_ForWhichID( SfxItemState::DEFAULT, nWhich, true, nullptr); + } + if (bHasItem) + rItemWhichs.push_back( nWhich ); + } + } +} + const SfxPoolItem* SfxItemSet::PutImplAsTargetWhich(const SfxPoolItem& rItem, sal_uInt16 nTargetWhich, bool bPassingOwnership) { if (0 == nTargetWhich || nTargetWhich == rItem.Which()) -- cgit