sc/inc/attrib.hxx | 2 ++ sc/source/core/data/attrib.cxx | 13 +++++++++++++ 2 files changed, 15 insertions(+)
New commits: commit 3d9f900c9e5466a66b9beeaa0d2b82c22063628a Author: Noel Grandin <[email protected]> AuthorDate: Thu May 22 11:53:12 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Mon May 26 10:53:37 2025 +0200 tdf#166684 make ScCondFormatItem hashable to speed up checking for duplicates. Shaves 3% off load time. Change-Id: Idea198e69f39eacbb98ab5ef10402e8f376637c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185770 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx index be3d78f4ce5e..f899f927c1ec 100644 --- a/sc/inc/attrib.hxx +++ b/sc/inc/attrib.hxx @@ -283,6 +283,8 @@ public: virtual ~ScCondFormatItem() override; virtual bool operator==(const SfxPoolItem& rCmp ) const override; + virtual bool supportsHashCode() const override; + virtual size_t hashCode() const override; virtual ScCondFormatItem* Clone( SfxItemPool* = nullptr ) const override; const ScCondFormatIndexes& GetCondFormatData() const { return maIndex;} diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx index 81f2f598ef89..058acab463c1 100644 --- a/sc/source/core/data/attrib.cxx +++ b/sc/source/core/data/attrib.cxx @@ -731,6 +731,19 @@ bool ScCondFormatItem::operator==( const SfxPoolItem& rCmp ) const && memcmp(&maIndex.front(), &other.maIndex.front(), maIndex.size() * sizeof(sal_uInt32)) == 0; } +bool ScCondFormatItem::supportsHashCode() const +{ + return true; +} + +size_t ScCondFormatItem::hashCode() const +{ + std::size_t seed = 0; + for (const auto & rIdx : maIndex) + o3tl::hash_combine(seed, rIdx); + return seed; +} + ScCondFormatItem* ScCondFormatItem::Clone(SfxItemPool*) const { return new ScCondFormatItem(maIndex);
