summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-02-21 00:57:21 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-02-21 12:29:49 +0100
commitb26c34267cdf9d0b7ba4e2fda7ae706d5cd76299 (patch)
tree8c73dfe528ebd3fab0d29485baebf5dfe9d3fbbc /svl
parent0723b41bed9bb4ad50d2993744a60177966d1a21 (diff)
replace SfxPoolItem::LookupHashCode() with Lookup() (tdf#135215)
The LookupHashCode() way still loops over an array while calling virtual functions for a type that is actually known. Overriding instead a whole new Lookup() function that does the loop avoids the virtual calls, allowing compiler optimizations such as inlining, or class-specific optimizations like the hash code. So this still improves performance with ScPatternAttr a bit, for tdf#135215 it saves about 40% of load time, but this is scraping the bottom of the barrel, as this is still a linear search (the IsSortable() approach, if it worked, would be still 3x faster). Change-Id: I8fe5f70cabb77e2f6619d169beee8a3b4da46213 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130228 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/itempool.cxx30
-rw-r--r--svl/source/items/sitem.cxx5
2 files changed, 10 insertions, 25 deletions
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index acd5c77de452..e13a1ffd60ea 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -625,30 +625,20 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW
if (pFoundItem)
assert(*pFoundItem == rItem);
}
+ else if(rItem.HasLookup())
+ {
+ auto it = rItem.Lookup(rItemArr.begin(), rItemArr.end());
+ if( it != rItemArr.end())
+ pFoundItem = *it;
+ }
else
{
- // If the item provides a valid hash, use that to speed up comparisons.
- size_t lookupHashCode = rItem.LookupHashCode();
- if (lookupHashCode != 0)
+ for (auto it = rItemArr.begin(); it != rItemArr.end(); ++it)
{
- for (auto itr = rItemArr.begin(); itr != rItemArr.end(); ++itr)
+ if (**it == rItem)
{
- if ((*itr)->LookupHashCode() == lookupHashCode && **itr == rItem)
- {
- pFoundItem = *itr;
- break;
- }
- }
- }
- else
- {
- for (auto itr = rItemArr.begin(); itr != rItemArr.end(); ++itr)
- {
- if (**itr == rItem)
- {
- pFoundItem = *itr;
- break;
- }
+ pFoundItem = *it;
+ break;
}
}
}
diff --git a/svl/source/items/sitem.cxx b/svl/source/items/sitem.cxx
index c4734d35c2f2..b6ffce978aef 100644
--- a/svl/source/items/sitem.cxx
+++ b/svl/source/items/sitem.cxx
@@ -51,11 +51,6 @@ SfxSetItem::SfxSetItem( const SfxSetItem& rCopy, SfxItemPool *pPool ) :
}
-SfxSetItem::~SfxSetItem()
-{
-}
-
-
bool SfxSetItem::operator==( const SfxPoolItem& rCmp) const
{
assert(SfxPoolItem::operator==(rCmp));