diff options
author | hdu <duerr@sun.com> | 2009-10-21 11:06:38 +0200 |
---|---|---|
committer | hdu <duerr@sun.com> | 2009-10-21 11:06:38 +0200 |
commit | b1419a4de2ff47d32cd7d93b4042727b05435fad (patch) | |
tree | 0b357493a17d7ebec87a5709ea48ab76369031b8 /basegfx | |
parent | 47185865ba1217151a0244de5855e5574114b327 (diff) |
#i106127# perf: add and use B2DPolygon::reserve() to prevent many reallocations
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/inc/basegfx/polygon/b2dpolygon.hxx | 1 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dpolygon.cxx | 15 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dpolygontools.cxx | 9 |
3 files changed, 25 insertions, 0 deletions
diff --git a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx index ee12d55d460b..1d5f8aaa4356 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx @@ -89,6 +89,7 @@ namespace basegfx /// Coordinate insert/append void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 nCount = 1); void append(const basegfx::B2DPoint& rPoint, sal_uInt32 nCount = 1); + void reserve(sal_uInt32 nCount); /// Basic ControlPoint interface basegfx::B2DPoint getPrevControlPoint(sal_uInt32 nIndex) const; diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index 467a4b90f516..d44599e0f49e 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -123,6 +123,11 @@ public: maVector[nIndex].setCoordinate(rValue); } + void reserve(sal_uInt32 nCount) + { + maVector.reserve(nCount); + } + void insert(sal_uInt32 nIndex, const CoordinateData2D& rValue, sal_uInt32 nCount) { if(nCount) @@ -741,6 +746,11 @@ public: maPoints.setCoordinate(nIndex, rValue); } + void reserve(sal_uInt32 nCount) + { + maPoints.reserve(nCount); + } + void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 nCount) { if(nCount) @@ -1190,6 +1200,11 @@ namespace basegfx } } + void B2DPolygon::reserve(sal_uInt32 nCount) + { + mpPolygon->reserve(nCount); + } + void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPoint& rPoint, sal_uInt32 nCount) { OSL_ENSURE(nIndex <= mpPolygon->count(), "B2DPolygon Insert outside range (!)"); diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index c1e5dc80d8c4..038ad0b35300 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -192,6 +192,9 @@ namespace basegfx B2DCubicBezier aBezier; aBezier.setStartPoint(rCandidate.getB2DPoint(0)); + // perf: try to avoid too many realloctions by guessing the result's pointcount + aRetval.reserve(nPointCount*4); + // add start point (always) aRetval.append(aBezier.getStartPoint()); @@ -272,6 +275,9 @@ namespace basegfx B2DCubicBezier aBezier; aBezier.setStartPoint(rCandidate.getB2DPoint(0)); + // perf: try to avoid too many realloctions by guessing the result's pointcount + aRetval.reserve(nPointCount*4); + // add start point (always) aRetval.append(aBezier.getStartPoint()); @@ -342,6 +348,9 @@ namespace basegfx B2DCubicBezier aBezier; aBezier.setStartPoint(rCandidate.getB2DPoint(0)); + // perf: try to avoid too many realloctions by guessing the result's pointcount + aRetval.reserve(nPointCount*4); + // add start point (always) aRetval.append(aBezier.getStartPoint()); |