diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-07-21 12:34:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-07-25 10:00:23 +0200 |
commit | 0351bec874f7e83c437e485e8d61a41f32718e25 (patch) | |
tree | 463fa37a7d8a9c990edb80e8f9cf726002c8aa4d /svl | |
parent | 9700c1b2170ad04453a361ed5647937833ac3c18 (diff) |
use more o3tl::span
which means we can reserve precisely the right number of entries when
building maps
Change-Id: I580414699289369de4730caae09829bbd8759e82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137292
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/itemprop.cxx | 22 | ||||
-rw-r--r-- | svl/source/numbers/numfmuno.cxx | 6 |
2 files changed, 13 insertions, 15 deletions
diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx index 56e3254b78f9..e8dd3ccd28ef 100644 --- a/svl/source/items/itemprop.cxx +++ b/svl/source/items/itemprop.cxx @@ -35,13 +35,13 @@ using namespace com::sun::star::beans; using namespace com::sun::star::lang; using namespace com::sun::star::uno; -SfxItemPropertyMap::SfxItemPropertyMap( const SfxItemPropertyMapEntry* pEntries ) +SfxItemPropertyMap::SfxItemPropertyMap( o3tl::span<const SfxItemPropertyMapEntry> pEntries ) { - m_aMap.reserve(128); - while( !pEntries->aName.isEmpty() ) + m_aMap.reserve(pEntries.size()); + for (const auto & pEntry : pEntries) { - m_aMap.insert( pEntries ); - ++pEntries; + assert(!pEntry.aName.isEmpty() && "empty name? might be something left an empty entry at the end of this array"); + m_aMap.insert( &pEntry ); } } @@ -246,7 +246,7 @@ SfxItemPropertySetInfo::SfxItemPropertySetInfo(const SfxItemPropertyMap &rMap ) { } -SfxItemPropertySetInfo::SfxItemPropertySetInfo(const SfxItemPropertyMapEntry *pEntries ) +SfxItemPropertySetInfo::SfxItemPropertySetInfo(o3tl::span<const SfxItemPropertyMapEntry> pEntries ) : m_aOwnMap( pEntries ) { } @@ -270,14 +270,14 @@ sal_Bool SAL_CALL SfxItemPropertySetInfo::hasPropertyByName( const OUString& rNa return m_aOwnMap.hasPropertyByName( rName ); } -SfxExtItemPropertySetInfo::SfxExtItemPropertySetInfo( const SfxItemPropertyMapEntry *pEntries, +SfxExtItemPropertySetInfo::SfxExtItemPropertySetInfo( o3tl::span<const SfxItemPropertyMapEntry> pEntries, const Sequence<Property>& rPropSeq ) { - maMap.reserve(16); - while( !pEntries->aName.isEmpty() ) + maMap.reserve(pEntries.size() + rPropSeq.getLength()); + for (const auto & rEntry : pEntries ) { - maMap.insert( *pEntries ); - ++pEntries; + assert(!rEntry.aName.isEmpty() && "empty name? might be something left an empty entry at the end of this array"); + maMap.insert( rEntry ); } for( const auto & rProp : rPropSeq ) { diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx index 8743ab578b4b..c95ec9f4f0e5 100644 --- a/svl/source/numbers/numfmuno.cxx +++ b/svl/source/numbers/numfmuno.cxx @@ -62,7 +62,7 @@ constexpr OUStringLiteral PROPERTYNAME_TWODIGIT = u"TwoDigitDateStart"; // All without a Which-ID, Map only for PropertySetInfo -static const SfxItemPropertyMapEntry* lcl_GetNumberFormatPropertyMap() +static o3tl::span<const SfxItemPropertyMapEntry> lcl_GetNumberFormatPropertyMap() { static const SfxItemPropertyMapEntry aNumberFormatPropertyMap_Impl[] = { @@ -79,12 +79,11 @@ static const SfxItemPropertyMapEntry* lcl_GetNumberFormatPropertyMap() {PROPERTYNAME_THOUS, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0}, {PROPERTYNAME_USERDEF, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0}, {PROPERTYNAME_CURRABB, 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY, 0}, - { u"", 0, css::uno::Type(), 0, 0 } }; return aNumberFormatPropertyMap_Impl; } -static const SfxItemPropertyMapEntry* lcl_GetNumberSettingsPropertyMap() +static o3tl::span<const SfxItemPropertyMapEntry> lcl_GetNumberSettingsPropertyMap() { static const SfxItemPropertyMapEntry aNumberSettingsPropertyMap_Impl[] = { @@ -92,7 +91,6 @@ static const SfxItemPropertyMapEntry* lcl_GetNumberSettingsPropertyMap() {PROPERTYNAME_NULLDATE, 0, cppu::UnoType<util::Date>::get(), beans::PropertyAttribute::BOUND, 0}, {PROPERTYNAME_STDDEC, 0, cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::BOUND, 0}, {PROPERTYNAME_TWODIGIT, 0, cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::BOUND, 0}, - { u"", 0, css::uno::Type(), 0, 0 } }; return aNumberSettingsPropertyMap_Impl; } |