summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-21 22:46:10 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 08:33:44 +0200
commit6c39f0665573e721e6913ba7b9b036d22154e6af (patch)
tree30abe777d382c9b7325a59b5111fa33ddbd228bc /comphelper
parentb63609ba5478ed9b020c113f5704f7ea8447dec8 (diff)
IndexedPropertyValuesContainer: remove iterators stupidity
It uses random-access iterators, so just use O(1) increments Change-Id: I9f80789d0bc03184d346c6814fd015bc06876acd Reviewed-on: https://gerrit.libreoffice.org/42606 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/container/IndexedPropertyValuesContainer.cxx51
1 files changed, 3 insertions, 48 deletions
diff --git a/comphelper/source/container/IndexedPropertyValuesContainer.cxx b/comphelper/source/container/IndexedPropertyValuesContainer.cxx
index 1853ba71918b..e095ebc785db 100644
--- a/comphelper/source/container/IndexedPropertyValuesContainer.cxx
+++ b/comphelper/source/container/IndexedPropertyValuesContainer.cxx
@@ -79,60 +79,15 @@ void SAL_CALL IndexedPropertyValuesContainer::insertByIndex( sal_Int32 nIndex, c
if (nSize == nIndex)
maProperties.push_back(aProps);
else
- {
- IndexedPropertyValues::iterator aItr;
- if ((nIndex * 2) < nSize)
- {
- aItr = maProperties.begin();
- sal_Int32 i(0);
- while(i < nIndex)
- {
- ++i;
- ++aItr;
- }
- }
- else
- {
- aItr = maProperties.end();
- sal_Int32 i(nSize);
- while(i > nIndex)
- {
- --i;
- --aItr;
- }
- }
- maProperties.insert(aItr, aProps);
- }
+ maProperties.insert(maProperties.begin() + nIndex, aProps);
}
void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex )
{
- sal_Int32 nSize(maProperties.size());
- if ((nIndex >= nSize) || (nIndex < 0))
+ if ((nIndex >= sal_Int32(maProperties.size())) || (nIndex < 0))
throw lang::IndexOutOfBoundsException();
- IndexedPropertyValues::iterator aItr;
- if ((nIndex * 2) < nSize)
- {
- aItr = maProperties.begin();
- sal_Int32 i(0);
- while(i < nIndex)
- {
- ++i;
- ++aItr;
- }
- }
- else
- {
- aItr = maProperties.end();
- sal_Int32 i(nSize);
- while(i > nIndex)
- {
- --i;
- --aItr;
- }
- }
- maProperties.erase(aItr);
+ maProperties.erase(maProperties.begin() + nIndex);
}
// XIndexReplace