Kaydet (Commit) 6c39f066 authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Noel Grandin

IndexedPropertyValuesContainer: remove iterators stupidity

It uses random-access iterators, so just use O(1) increments

Change-Id: I9f80789d0bc03184d346c6814fd015bc06876acd
Reviewed-on: https://gerrit.libreoffice.org/42606Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst b63609ba
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment