From 406092f60abbb258bbd1fc6f2d09e7a669af943b Mon Sep 17 00:00:00 2001 From: hdu Date: Thu, 22 Oct 2009 16:54:19 +0200 Subject: #i106127# perf: using vector.push_back() instead of the generic vector.insertAtWithCount() is worth it when it gets called a gazillion times --- basegfx/source/polygon/b2dpolygon.cxx | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'basegfx/source') diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index d44599e0f49e..48d00ddcec7d 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -7,7 +7,6 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: b2dpolygon.cxx,v $ - * $Revision: 1.22 $ * * This file is part of OpenOffice.org. * @@ -128,6 +127,11 @@ public: maVector.reserve(nCount); } + void append(const CoordinateData2D& rValue) + { + maVector.push_back(rValue); + } + void insert(sal_uInt32 nIndex, const CoordinateData2D& rValue, sal_uInt32 nCount) { if(nCount) @@ -385,6 +389,17 @@ public: } } + void append(const ControlVectorPair2D& rValue) + { + maVector.push_back(rValue); + + if(!rValue.getPrevVector().equalZero()) + mnUsedVectors += 1; + + if(!rValue.getNextVector().equalZero()) + mnUsedVectors += 1; + } + void insert(sal_uInt32 nIndex, const ControlVectorPair2D& rValue, sal_uInt32 nCount) { if(nCount) @@ -751,6 +766,19 @@ public: maPoints.reserve(nCount); } + void append(const basegfx::B2DPoint& rPoint) + { + mpBufferedData.reset(); // TODO: is this needed? + const CoordinateData2D aCoordinate(rPoint); + maPoints.append(aCoordinate); + + if(mpControlVector) + { + const ControlVectorPair2D aVectorPair; + mpControlVector->append(aVectorPair); + } + } + void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 nCount) { if(nCount) @@ -1223,6 +1251,11 @@ namespace basegfx } } + void B2DPolygon::append(const B2DPoint& rPoint) + { + mpPolygon->append(rPoint); + } + B2DPoint B2DPolygon::getPrevControlPoint(sal_uInt32 nIndex) const { OSL_ENSURE(nIndex < mpPolygon->count(), "B2DPolygon access outside range (!)"); -- cgit v1.2.3