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 /include | |
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 'include')
-rw-r--r-- | include/comphelper/attributelist.hxx | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/include/comphelper/attributelist.hxx b/include/comphelper/attributelist.hxx index 91635a412765..8d9248fd57c2 100644 --- a/include/comphelper/attributelist.hxx +++ b/include/comphelper/attributelist.hxx @@ -23,6 +23,7 @@ #include <sal/config.h> #include <memory> +#include <vector> #include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp> @@ -32,12 +33,17 @@ namespace comphelper { -struct AttributeList_Impl; +struct TagAttribute +{ + OUString sName; + OUString sType; + OUString sValue; +}; class COMPHELPER_DLLPUBLIC AttributeList : public ::cppu::WeakImplHelper<css::xml::sax::XAttributeList, css::util::XCloneable> { - std::unique_ptr<AttributeList_Impl> m_pImpl; + std::vector<TagAttribute> mAttributes; public: AttributeList(); AttributeList(const AttributeList &r); @@ -45,15 +51,33 @@ public: virtual ~AttributeList() override; // methods that are not contained in any interface - void AddAttribute(const OUString &sName , const OUString &sType , const OUString &sValue); - void Clear(); + void AddAttribute(const OUString &sName , const OUString &sType , const OUString &sValue) + { + mAttributes.push_back({sName, sType, sValue}); + } + void Clear() + { + mAttributes.clear(); + } // css::xml::sax::XAttributeList - virtual sal_Int16 SAL_CALL getLength() override; - virtual OUString SAL_CALL getNameByIndex(sal_Int16 i) override; - virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i) override; + virtual sal_Int16 SAL_CALL getLength() override + { + return static_cast<sal_Int16>(mAttributes.size()); + } + virtual OUString SAL_CALL getNameByIndex(sal_Int16 i) override + { + return mAttributes[i].sName; + } + virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i) override + { + return mAttributes[i].sType; + } virtual OUString SAL_CALL getTypeByName(const OUString& aName) override; - virtual OUString SAL_CALL getValueByIndex(sal_Int16 i) override; + virtual OUString SAL_CALL getValueByIndex(sal_Int16 i) override + { + return mAttributes[i].sValue; + } virtual OUString SAL_CALL getValueByName(const OUString& aName) override; // css::util::XCloneable |