diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-09-24 14:20:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-25 19:04:52 +0200 |
commit | 03998c25358f88a9fd6ac306ad1aba81fceca0fe (patch) | |
tree | fe88512a4d8386af56ac0fb1f0e47b9c443827bb /include | |
parent | 398ae49ba337a2d2c32611f371132c978cf4db64 (diff) |
use SfxItemSetFixed in svx
Change-Id: I8123b34c73a16579b59989ae31329dec378d8b98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122584
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/svl/itemset.hxx | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index f0ea42835073..5ce13bb1f4c8 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -225,16 +225,32 @@ private: }; +namespace svl::detail +{ +/** + * Determines the number of sal_uInt16s in a container of pairs of + * sal_uInt16s, each representing a range of sal_uInt16s, and total capacity of the ranges. + */ +template <sal_uInt16 WID1, sal_uInt16 WID2, sal_uInt16... Rest> +static constexpr sal_uInt16 CountRanges1() +{ + sal_uInt16 nCapacity = rangeSize(WID1, WID2); + if constexpr (sizeof...(Rest) > 0) + nCapacity += CountRanges1<Rest...>(); + return nCapacity; +}} + // Allocate the items array inside the object, to reduce allocation cost. // -template<sal_uInt16 nWID1, sal_uInt16 nWID2> +template<sal_uInt16... WIDs> class SfxItemSetFixed : public SfxItemSet { public: SfxItemSetFixed( SfxItemPool& rPool) - : SfxItemSet(rPool, WhichRangesContainer(svl::Items_t<nWID1, nWID2>{}), m_aItems) {} + : SfxItemSet(rPool, WhichRangesContainer(svl::Items_t<WIDs...>{}), m_aItems) {} private: - const SfxPoolItem* m_aItems[nWID2 - nWID1 + 1] = {}; + static constexpr sal_uInt16 NITEMS = svl::detail::CountRanges1<WIDs...>(); + const SfxPoolItem* m_aItems[NITEMS] = {}; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |