diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-02-20 00:56:37 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-02-20 07:59:01 +0100 |
commit | 131710cba68e46c175babbd20c810e7fc2fb811f (patch) | |
tree | 8a61e5748a336964dfc59c431835db8048294cd4 /sc | |
parent | b965efc0ab5d6996417c92b5588e9d1ff79e0572 (diff) |
optimize AreaBroadcast() a bit
Use ComputeAreaPoints() rather than repeated ComputeSlotOffset().
Change-Id: If7869fe4c37a1e844ec9e6513a7c1799290c077f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130204
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/bcaslot.cxx | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 6869ca24e120..7e6383a9c35b 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -909,24 +909,23 @@ bool ScBroadcastAreaSlotMachine::AreaBroadcast( const ScHint& rHint ) const TableSlotsMap::const_iterator iTab( aTableSlotsMap.find( rAddress.Tab())); if (iTab == aTableSlotsMap.end()) return false; - // Process all slots for the given row range, but it's enough to process - // each only once. - ScBroadcastAreaSlot* pLastSlot = nullptr; - ScAddress address(rAddress); - bool wasBroadcast = false; - for( SCROW nRow = rAddress.Row(); nRow < rAddress.Row() + rHint.GetRowCount(); ++nRow ) + // Process all slots for the given row range. + ScRange broadcastRange( rAddress, + ScAddress( rAddress.Col(), rAddress.Row() + rHint.GetRowCount() - 1, rAddress.Tab())); + bool bBroadcasted = false; + ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots(); + SCSIZE nStart, nEnd, nRowBreak; + ComputeAreaPoints( broadcastRange, nStart, nEnd, nRowBreak ); + SCSIZE nOff = nStart; + SCSIZE nBreak = nOff + nRowBreak; + ScBroadcastAreaSlot** pp = ppSlots + nOff; + while ( nOff <= nEnd ) { - address.SetRow(nRow); - ScBroadcastAreaSlot* pSlot = (*iTab).second->getAreaSlot( - ComputeSlotOffset( address)); - if ( pSlot && pSlot != pLastSlot ) - { - if(pSlot->AreaBroadcast( rHint )) - wasBroadcast = true; - pLastSlot = pSlot; - } + if ( *pp ) + bBroadcasted |= (*pp)->AreaBroadcast( rHint ); + ComputeNextSlot( nOff, nBreak, pp, nStart, ppSlots, nRowBreak, mnBcaSlotsCol); } - return wasBroadcast; + return bBroadcasted; } } |