diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-05-15 12:55:02 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-05-20 20:13:07 -0400 |
commit | bad98d1b26f76192dcf7f935060a9928b8442585 (patch) | |
tree | 237b6083643da5edc14cc6e19a72315a4c4e20bc /sc | |
parent | bb77c4b5e6a8c22f8d068541bd7564f98c5d3fdd (diff) |
Avoid expensive element position lookup twice.
This moderately improves the performance of pasting a large array
of formula cells.
Change-Id: I27a59ff348cb715df15db80693cb7d193e67ec2e
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/column2.cxx | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index ea0aac3946ce..037a02ce3b29 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1864,13 +1864,37 @@ void ScColumn::FindUsed( SCROW nStartRow, SCROW nEndRow, bool* pUsed ) const void ScColumn::StartListening( SvtListener& rLst, SCROW nRow ) { - SvtBroadcaster* pBC = GetBroadcaster(nRow); - if (!pBC) + std::pair<BCStoreType::iterator,size_t> aPos = maBroadcasters.position(nRow); + BCStoreType::iterator it = aPos.first; // block position. + size_t nElemPos = aPos.second; // element position within the block. + switch (it->type) { - pBC = new SvtBroadcaster; - maBroadcasters.set(nRow, pBC); + case sc::element_type_broadcaster: + { + // Broadcaster already exists here. + sc::custom_broadcaster_block::iterator itData = sc::custom_broadcaster_block::begin(*it->data); + std::advance(itData, nElemPos); + SvtBroadcaster* pBC = *itData; + rLst.StartListening(*pBC); + } + break; + case mdds::mtv::element_type_empty: + { + // No broadcaster exists at this position yet. + SvtBroadcaster* pBC = new SvtBroadcaster; + rLst.StartListening(*pBC); + maBroadcasters.set(it, nRow, pBC); + } + break; + default: +#if DEBUG_COLUMN_STORAGE + cout << "ScColumn::StartListening: wrong block type encountered in the broadcaster storage." << endl; + cout.flush(); + abort(); +#else + ; +#endif } - rLst.StartListening(*pBC); } void ScColumn::MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow ) |