diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-27 09:44:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-29 08:30:17 +0200 |
commit | 8647288180806f8515bf2548db7280cbc657eaf3 (patch) | |
tree | cde7f2e1547373f816ae583926fac2d6ddc4a5e6 /comphelper | |
parent | beacd77aa985ed90532cd5fdd7b56314c0a7b0eb (diff) |
optimise comphelper::AttributeList a little
Change-Id: I48cb0a1b5dfcf6471c1cdf9d79445281f9f33020
Reviewed-on: https://gerrit.libreoffice.org/71463
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/xml/attributelist.cxx | 70 |
1 files changed, 5 insertions, 65 deletions
diff --git a/comphelper/source/xml/attributelist.cxx b/comphelper/source/xml/attributelist.cxx index 6c1578defd8f..fa918d01da29 100644 --- a/comphelper/source/xml/attributelist.cxx +++ b/comphelper/source/xml/attributelist.cxx @@ -27,57 +27,9 @@ using namespace com::sun::star; namespace comphelper { -struct TagAttribute_Impl -{ - TagAttribute_Impl( const OUString &aName, const OUString &aType, - const OUString &aValue ) - { - sName = aName; - sType = aType; - sValue = aValue; - } - - OUString sName; - OUString sType; - OUString sValue; -}; - -struct AttributeList_Impl -{ - AttributeList_Impl() - { - // performance improvement during adding - vecAttribute.reserve(20); - } - std::vector<struct TagAttribute_Impl> vecAttribute; -}; - -sal_Int16 SAL_CALL AttributeList::getLength() -{ - return static_cast<sal_Int16>(m_pImpl->vecAttribute.size()); -} - -OUString SAL_CALL AttributeList::getNameByIndex(sal_Int16 i) -{ - return ( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size()) ) ? m_pImpl->vecAttribute[i].sName : OUString(); -} - -OUString SAL_CALL AttributeList::getTypeByIndex(sal_Int16 i) -{ - if( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size() ) ) { - return m_pImpl->vecAttribute[i].sType; - } - return OUString(); -} - -OUString SAL_CALL AttributeList::getValueByIndex(sal_Int16 i) -{ - return ( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size() ) ) ? m_pImpl->vecAttribute[i].sValue : OUString(); -} - OUString SAL_CALL AttributeList::getTypeByName( const OUString& sName ) { - for (auto const& attribute : m_pImpl->vecAttribute) + for (auto const& attribute : mAttributes) { if( attribute.sName == sName ) { return attribute.sType; @@ -88,7 +40,7 @@ OUString SAL_CALL AttributeList::getTypeByName( const OUString& sName ) OUString SAL_CALL AttributeList::getValueByName(const OUString& sName) { - for (auto const& attribute : m_pImpl->vecAttribute) + for (auto const& attribute : mAttributes) { if( attribute.sName == sName ) { return attribute.sValue; @@ -98,34 +50,22 @@ OUString SAL_CALL AttributeList::getValueByName(const OUString& sName) } AttributeList::AttributeList() - : m_pImpl(new AttributeList_Impl) { + // performance improvement during adding + mAttributes.reserve(20); } AttributeList::AttributeList(const AttributeList &r) : cppu::WeakImplHelper<XAttributeList, XCloneable>(r) - , m_pImpl(new AttributeList_Impl) { - *m_pImpl = *(r.m_pImpl); + mAttributes = r.mAttributes; } AttributeList::~AttributeList() { } -void AttributeList::AddAttribute(const OUString &sName, - const OUString &sType, const OUString &sValue) -{ - m_pImpl->vecAttribute.emplace_back(sName, sType, sValue ); -} - -void AttributeList::Clear() -{ - m_pImpl->vecAttribute.clear(); -} - css::uno::Reference< css::util::XCloneable > AttributeList::createClone() - { AttributeList *p = new AttributeList( *this ); return css::uno::Reference< css::util::XCloneable > ( static_cast<css::util::XCloneable *>(p) ); |