summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-03-13 21:11:09 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-03-16 20:16:46 +0100
commit10a48c737d347bcce765c8fbe009bc1dd0bb0c4d (patch)
tree6688e9ca36964bcbf589e60452a331b49a81bfde /basegfx
parentbb9728bbf9bb29ef2b6ca582a382f66e9adf2623 (diff)
Simplify containers iterations in basctl, basegfx, basic, bridges
Use range-based loop or replace with STL functions Change-Id: I8594740103bdc2091c2d03d4b92bbe8393f5378c Reviewed-on: https://gerrit.libreoffice.org/69223 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/polygon/b3dpolygon.cxx48
-rw-r--r--basegfx/test/boxclipper.cxx4
2 files changed, 17 insertions, 35 deletions
diff --git a/basegfx/source/polygon/b3dpolygon.cxx b/basegfx/source/polygon/b3dpolygon.cxx
index 9817fb43f6fb..5d23be90562c 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -335,11 +335,8 @@ public:
BColorDataVector::const_iterator aEnd(rSource.maVector.end());
maVector.insert(aIndex, aStart, aEnd);
- for(; aStart != aEnd; ++aStart)
- {
- if(!aStart->equalZero())
- mnUsedEntries++;
- }
+ mnUsedEntries += std::count_if(aStart, aEnd,
+ [](BColorDataVector::const_reference rData) { return !rData.equalZero(); });
}
}
@@ -349,13 +346,10 @@ public:
{
const BColorDataVector::iterator aDeleteStart(maVector.begin() + nIndex);
const BColorDataVector::iterator aDeleteEnd(aDeleteStart + nCount);
- BColorDataVector::const_iterator aStart(aDeleteStart);
- for(; mnUsedEntries && aStart != aDeleteEnd; ++aStart)
- {
- if(!aStart->equalZero())
- mnUsedEntries--;
- }
+ auto nDeleteUsed = std::count_if(aDeleteStart, aDeleteEnd,
+ [](BColorDataVector::const_reference rData) { return !rData.equalZero(); });
+ mnUsedEntries -= std::min(mnUsedEntries, static_cast<sal_uInt32>(nDeleteUsed));
// remove point data
maVector.erase(aDeleteStart, aDeleteEnd);
@@ -482,11 +476,8 @@ public:
NormalsData3DVector::const_iterator aEnd(rSource.maVector.end());
maVector.insert(aIndex, aStart, aEnd);
- for(; aStart != aEnd; ++aStart)
- {
- if(!aStart->equalZero())
- mnUsedEntries++;
- }
+ mnUsedEntries += std::count_if(aStart, aEnd,
+ [](NormalsData3DVector::const_reference rData) { return !rData.equalZero(); });
}
}
@@ -496,13 +487,10 @@ public:
{
const NormalsData3DVector::iterator aDeleteStart(maVector.begin() + nIndex);
const NormalsData3DVector::iterator aDeleteEnd(aDeleteStart + nCount);
- NormalsData3DVector::const_iterator aStart(aDeleteStart);
- for(; mnUsedEntries && aStart != aDeleteEnd; ++aStart)
- {
- if(!aStart->equalZero())
- mnUsedEntries--;
- }
+ auto nDeleteUsed = std::count_if(aDeleteStart, aDeleteEnd,
+ [](NormalsData3DVector::const_reference rData) { return !rData.equalZero(); });
+ mnUsedEntries -= std::min(mnUsedEntries, static_cast<sal_uInt32>(nDeleteUsed));
// remove point data
maVector.erase(aDeleteStart, aDeleteEnd);
@@ -637,11 +625,8 @@ public:
TextureData2DVector::const_iterator aEnd(rSource.maVector.end());
maVector.insert(aIndex, aStart, aEnd);
- for(; aStart != aEnd; ++aStart)
- {
- if(!aStart->equalZero())
- mnUsedEntries++;
- }
+ mnUsedEntries += std::count_if(aStart, aEnd,
+ [](TextureData2DVector::const_reference rData) { return !rData.equalZero(); });
}
}
@@ -651,13 +636,10 @@ public:
{
const TextureData2DVector::iterator aDeleteStart(maVector.begin() + nIndex);
const TextureData2DVector::iterator aDeleteEnd(aDeleteStart + nCount);
- TextureData2DVector::const_iterator aStart(aDeleteStart);
- for(; mnUsedEntries && aStart != aDeleteEnd; ++aStart)
- {
- if(!aStart->equalZero())
- mnUsedEntries--;
- }
+ auto nDeleteUsed = std::count_if(aDeleteStart, aDeleteEnd,
+ [](TextureData2DVector::const_reference rData) { return !rData.equalZero(); });
+ mnUsedEntries -= std::min(mnUsedEntries, static_cast<sal_uInt32>(nDeleteUsed));
// remove point data
maVector.erase(aDeleteStart, aDeleteEnd);
diff --git a/basegfx/test/boxclipper.cxx b/basegfx/test/boxclipper.cxx
index 0987daf9d929..d7c7c094b962 100644
--- a/basegfx/test/boxclipper.cxx
+++ b/basegfx/test/boxclipper.cxx
@@ -189,8 +189,8 @@ public:
std::rotate(aTmp2.begin(),pSmallest,aTmp2.end());
aTmp.clear();
- for(std::vector<B2DPoint>::iterator pCurr=aTmp2.begin(); pCurr!=aTmp2.end(); ++pCurr)
- aTmp.append(*pCurr);
+ for(const auto& rCurr : aTmp2)
+ aTmp.append(rCurr);
aRes.append(aTmp);
}