From d4f61a594608219d08b489205ebb5569d905f444 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 2 Feb 2022 09:52:49 +0200 Subject: no point in mapping SID to itself and once we remove that self mapping, no need to call GetWhich for those IDs either Change-Id: Ia881328a29bb022dace8d5f25c57279a381e0377 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129321 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svl/qa/unit/items/stylepool.cxx | 2 +- svl/qa/unit/items/test_itempool.cxx | 8 ++++---- svl/source/items/itempool.cxx | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'svl') diff --git a/svl/qa/unit/items/stylepool.cxx b/svl/qa/unit/items/stylepool.cxx index 01f0d8867b48..94ff91aea73c 100644 --- a/svl/qa/unit/items/stylepool.cxx +++ b/svl/qa/unit/items/stylepool.cxx @@ -26,7 +26,7 @@ CPPUNIT_TEST_FIXTURE(StylePoolTest, testIterationOrder) // Set up a style pool with multiple parents. SfxStringItem aDefault1(1); std::vector aDefaults{ &aDefault1 }; - SfxItemInfo const aItems[] = { { 1, false } }; + SfxItemInfo const aItems[] = { { 2, false } }; rtl::Reference pPool = new SfxItemPool("test", 1, 1, aItems); pPool->SetDefaults(&aDefaults); diff --git a/svl/qa/unit/items/test_itempool.cxx b/svl/qa/unit/items/test_itempool.cxx index 4d15edaffd86..6868999f0f76 100644 --- a/svl/qa/unit/items/test_itempool.cxx +++ b/svl/qa/unit/items/test_itempool.cxx @@ -34,10 +34,10 @@ class PoolItemTest : public CppUnit::TestFixture void PoolItemTest::testPool() { SfxItemInfo const aItems[] = - { { 1, true }, - { 2, false /* not poolable */ }, - { 3, false }, - { 4, false /* not poolable */} + { { 4, true }, + { 3, false /* not poolable */ }, + { 2, false }, + { 1, false /* not poolable */} }; rtl::Reference pPool = new SfxItemPool("testpool", 1, 4, aItems); diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index fe13cfb96a32..8d4aa074e4f5 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -167,6 +167,24 @@ SfxItemPool::SfxItemPool if ( pDefaults ) SetDefaults(pDefaults); + +#ifdef DBG_UTIL + if (pItemInfos) + { + auto p = pItemInfos; + auto nWhich = nStartWhich; + while (nWhich <= nEndWhich) + { + if (p->_nSID == nWhich) + { + SAL_WARN("svl.items", "No point mapping a SID to itself, just put a 0 here in the SfxItemInfo array, at index " << (p - pItemInfos)); + assert(false); + } + ++p; + ++nWhich; + } + } +#endif } -- cgit