From 8a545ef39f6177f5da536186a4e3b41f9eaae75d Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Sat, 26 Dec 2020 11:13:02 +0100 Subject: std::list::size() has constant complexity since C++11 Change-Id: I18cfbf84e1ca2cc6d3a7e7f01e943ef8afb23362 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108334 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basegfx/source/polygon/b2dtrapezoid.cxx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'basegfx/source') diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx b/basegfx/source/polygon/b2dtrapezoid.cxx index 5648aa3be81c..f30001f52d2a 100644 --- a/basegfx/source/polygon/b2dtrapezoid.cxx +++ b/basegfx/source/polygon/b2dtrapezoid.cxx @@ -252,7 +252,6 @@ namespace basegfx::trapezoidhelper { private: // local data - sal_uInt32 mnInitialEdgeEntryCount; TrDeEdgeEntries maTrDeEdgeEntries; std::vector< B2DPoint > maPoints; /// new points allocated for cuts @@ -483,8 +482,7 @@ namespace basegfx::trapezoidhelper public: explicit TrapezoidSubdivider( const B2DPolyPolygon& rSourcePolyPolygon) - : mnInitialEdgeEntryCount(0), - maTrDeEdgeEntries(), + : maTrDeEdgeEntries(), maPoints(), maNewPoints() { @@ -567,7 +565,6 @@ namespace basegfx::trapezoidhelper // vertical edge. Positive Y-direction is guaranteed by the // TrDeEdgeEntry constructor maTrDeEdgeEntries.emplace_back(pPrev, pCurr, 0); - mnInitialEdgeEntryCount++; } // prepare next step @@ -617,11 +614,8 @@ namespace basegfx::trapezoidhelper if(!maTrDeEdgeEntries.empty()) { // measuring shows that the relation between edges and created trapezoids is - // mostly in the 1:1 range, thus reserve as much trapezoids as edges exist. Do - // not use maTrDeEdgeEntries.size() since that may be a non-constant time - // operation for Lists. Instead, use mnInitialEdgeEntryCount which will contain - // the roughly counted adds to the List - ro_Result.reserve(ro_Result.size() + mnInitialEdgeEntryCount); + // mostly in the 1:1 range, thus reserve as much trapezoids as edges exist. + ro_Result.reserve(ro_Result.size() + maTrDeEdgeEntries.size()); } while(!maTrDeEdgeEntries.empty()) -- cgit