summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-09-11 09:13:26 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-09-11 10:34:59 +0200
commit5b51ca963903dd1fb74e8314fa556b510d5f7ee9 (patch)
treee751455eb2ec831254a57f8d51fe08a69a3ac00a /xmloff
parent3a22f5a589e822e7ca8bbb00e38a3aff93ed7ba5 (diff)
optimisation: use o3tl::sorted_vector in XMLPropertyStates_Impl
Change-Id: I9774e0d3f29decedd910fafe3c3174bab930f521 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102438 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/style/xmlexppr.cxx49
1 files changed, 12 insertions, 37 deletions
diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx
index 92ba262a1921..b65669aed3c3 100644
--- a/xmloff/source/style/xmlexppr.cxx
+++ b/xmloff/source/style/xmlexppr.cxx
@@ -32,6 +32,7 @@
#include <osl/diagnose.h>
#include <list>
#include <map>
+#include <o3tl/sorted_vector.hxx>
#include <xmloff/xmlexppr.hxx>
#include <xmloff/xmltoken.hxx>
@@ -91,62 +92,36 @@ XMLPropTokens_Impl const aPropTokens[MAX_PROP_TYPES] =
// if a state is available.
// After that I call the method 'ContextFilter'.
-typedef std::list<XMLPropertyState> XMLPropertyStateList_Impl;
-
+struct ComparePropertyState
+{
+ bool operator()(XMLPropertyState const& lhs, XMLPropertyState const& rhs)
+ {
+ return lhs.mnIndex < rhs.mnIndex;
+ }
+};
class XMLPropertyStates_Impl
{
- XMLPropertyStateList_Impl aPropStates;
- XMLPropertyStateList_Impl::iterator aLastItr;
- sal_uInt32 nCount;
+ o3tl::sorted_vector<XMLPropertyState, ComparePropertyState> aPropStates;
public:
XMLPropertyStates_Impl();
void AddPropertyState(const XMLPropertyState& rPropState);
void FillPropertyStateVector(std::vector<XMLPropertyState>& rVector);
};
-XMLPropertyStates_Impl::XMLPropertyStates_Impl() :
- aPropStates(),
- nCount(0)
+XMLPropertyStates_Impl::XMLPropertyStates_Impl()
{
- aLastItr = aPropStates.begin();
}
void XMLPropertyStates_Impl::AddPropertyState(
const XMLPropertyState& rPropState)
{
- XMLPropertyStateList_Impl::iterator aItr = aPropStates.begin();
- bool bInserted(false);
- if (nCount)
- {
- if (aLastItr->mnIndex < rPropState.mnIndex)
- aItr = ++aLastItr;
- }
- do
- {
- // TODO: one path required only
- if (aItr == aPropStates.end())
- {
- aLastItr = aPropStates.insert(aPropStates.end(), rPropState);
- bInserted = true;
- nCount++;
- }
- else if (aItr->mnIndex > rPropState.mnIndex)
- {
- aLastItr = aPropStates.insert(aItr, rPropState);
- bInserted = true;
- nCount++;
- }
- }
- while(!bInserted && (aItr++ != aPropStates.end()));
+ aPropStates.insert(rPropState);
}
void XMLPropertyStates_Impl::FillPropertyStateVector(
std::vector<XMLPropertyState>& rVector)
{
- if (nCount)
- {
- rVector.insert( rVector.begin(), aPropStates.begin(), aPropStates.end() );
- }
+ rVector.insert( rVector.begin(), aPropStates.begin(), aPropStates.end() );
}
class FilterPropertyInfo_Impl