sc/inc/attrib.hxx | 2 ++ sc/source/core/data/attrib.cxx | 13 +++++++++++++ 2 files changed, 15 insertions(+)
New commits: commit 80d54fb843f660d574f41f03c6297811f3ef1a12 Author: Noel Grandin <[email protected]> AuthorDate: Thu May 22 11:53:12 2025 +0200 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Sun Jun 15 22:54:29 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/+/185783 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx index 82cb056fbb10..102b92cbd99d 100644 --- a/sc/inc/attrib.hxx +++ b/sc/inc/attrib.hxx @@ -287,6 +287,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 21e7cb350756..c2583cb47908 100644 --- a/sc/source/core/data/attrib.cxx +++ b/sc/source/core/data/attrib.cxx @@ -733,6 +733,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);
