comphelper/source/container/IndexedPropertyValuesContainer.cxx | 51 ---------- 1 file changed, 3 insertions(+), 48 deletions(-)
New commits: commit 6c39f0665573e721e6913ba7b9b036d22154e6af Author: Mike Kaganski <[email protected]> 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 <[email protected]> Reviewed-by: Noel Grandin <[email protected]> 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 _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
