[Libreoffice-commits] core.git: comphelper/source

Mike Kaganski mike.kaganski at collabora.com
Fri Sep 22 06:34:16 UTC 2017


 comphelper/source/container/IndexedPropertyValuesContainer.cxx |   51 ----------
 1 file changed, 3 insertions(+), 48 deletions(-)

New commits:
commit 6c39f0665573e721e6913ba7b9b036d22154e6af
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Sep 21 22:46:10 2017 +0300

    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 at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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


More information about the Libreoffice-commits mailing list