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 <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Noel Grandin 2024-06-20 14:11:09 +02:00
parent 2ab4c442a5
commit 1be12e6d29
3 changed files with 27 additions and 9 deletions

View file

@ -212,6 +212,7 @@ public:
template<class T>
bool HasItem(TypedWhichId<T> nWhich, const T** ppItem = nullptr) const
{ return HasItem(sal_uInt16(nWhich), reinterpret_cast<const SfxPoolItem**>(ppItem)); }
void CollectHasItems(std::vector<sal_uInt16>& rItemWhichs) const;
void DisableItem(sal_uInt16 nWhich)
{ DisableOrInvalidateItem_ForWhichID(true, nWhich); }

View file

@ -929,6 +929,31 @@ bool SfxItemSet::HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem) const
return bRet;
}
void SfxItemSet::CollectHasItems(std::vector<sal_uInt16>& 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())

View file

@ -3099,15 +3099,7 @@ bool SwpHints::TryInsertHint(
rNode.SetCalcHiddenCharFlags();
// fdo#71556: populate aWhichFormatAttr member of SwMsgPoolItem
const WhichRangesContainer& pRanges = pSet->GetRanges();
for(auto const & rPair : pRanges)
{
const sal_uInt16 nBeg = rPair.first;
const sal_uInt16 nEnd = rPair.second;
for( sal_uInt16 nSubElem = nBeg; nSubElem <= nEnd; ++nSubElem )
if( pSet->HasItem( nSubElem ) )
aWhichSublist.push_back( nSubElem );
}
pSet->CollectHasItems(aWhichSublist);
break;
}
case RES_TXTATR_INETFMT: