diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-23 10:38:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-23 13:19:56 +0200 |
commit | 00aa9f622c29aecc6bb9c5ee4b3aa35a9afb095d (patch) | |
tree | 6b10baae17781ad810d0f7b7c08cc30945fa6246 /svl/source/items/itemiter.cxx | |
parent | b0730ff656848f005838b10bef0cf88f5ac0ba32 (diff) |
Revert "used std::map in SfxItemSet"
This reverts commit 2757ee9fe610e253e4ccc37423fa420004d0f388.
Besides causing a performance regression, I now notice that
there is code in SW that relies on iterating over two different
SfxItemSet's in parallel, and assumes that missing items are
returned as nullptr, which is not the case for my std::map based
change.
Change-Id: I2b1110350fe4c4b74e5508558e9661ef1e1a103e
Diffstat (limited to 'svl/source/items/itemiter.cxx')
-rw-r--r-- | svl/source/items/itemiter.cxx | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/svl/source/items/itemiter.cxx b/svl/source/items/itemiter.cxx index e1e8baade8be..a42a90bc2358 100644 --- a/svl/source/items/itemiter.cxx +++ b/svl/source/items/itemiter.cxx @@ -25,50 +25,44 @@ SfxItemIter::SfxItemIter( const SfxItemSet& rItemSet ) : m_rSet( rItemSet ) { - // store the set of keys because client code likes modifying the map - // while iterating over it - m_keys.resize(rItemSet.m_aItems.size()); - size_t idx = 0; - for (auto const & rPair : rItemSet.m_aItems) { - m_keys[idx++] = rPair.first; + if (!m_rSet.m_nCount) + { + m_nStart = 1; + m_nEnd = 0; } - m_iter = m_keys.begin(); -} + else + { + SfxItemArray ppFnd = m_rSet.m_pItems; -SfxItemIter::~SfxItemIter() -{ -} + // Find the first Item that is set + for (m_nStart = 0; !*(ppFnd + m_nStart ); ++m_nStart) + ; // empty loop + if (1 < m_rSet.Count()) + for (m_nEnd = m_rSet.TotalCount(); !*(ppFnd + --m_nEnd); ) + ; // empty loop + else + m_nEnd = m_nStart; + } -SfxPoolItem const * SfxItemIter::FirstItem() -{ - m_iter = m_keys.begin(); - return GetCurItem(); + m_nCurrent = m_nStart; } -SfxPoolItem const * SfxItemIter::GetCurItem() +SfxItemIter::~SfxItemIter() { - if (m_keys.empty()) - return nullptr; - auto it = m_rSet.m_aItems.find(*m_iter); - if (it == m_rSet.m_aItems.end()) - return nullptr; - return it->second; } -SfxPoolItem const * SfxItemIter::NextItem() +const SfxPoolItem* SfxItemIter::NextItem() { - if (m_iter == m_keys.end()) - return nullptr; - ++m_iter; - if (m_iter == m_keys.end()) - return nullptr; - return GetCurItem(); -} + SfxItemArray ppFnd = m_rSet.m_pItems; -bool SfxItemIter::IsAtEnd() const -{ - return m_iter == m_keys.end() || std::next(m_iter) == m_keys.end(); + if (m_nCurrent < m_nEnd) + { + do { + m_nCurrent++; + } while (m_nCurrent < m_nEnd && !*(ppFnd + m_nCurrent )); + return *(ppFnd+m_nCurrent); + } + return nullptr; } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |