summaryrefslogtreecommitdiff
path: root/basegfx/source/polygon
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@suse.com>2011-12-13 19:18:39 +0100
committerThorsten Behrens <tbehrens@suse.com>2011-12-13 20:58:39 +0100
commit7b7c3b6e1102e7f8856f047fe475ddbc53438f4e (patch)
tree41c1f1a879bdaa0bf329ec159923d58b918ec90d /basegfx/source/polygon
parentb43fb02c9b7afcbb41b5140b80e97447b1a29945 (diff)
More efficient insertion of B3DPolygons
* some cleanup - removed ugly-as-hell exposure of only parts of the internal data struct on B2DPolygon (and reworked the only client of that code) * added stl-style begin/end to B3DPolyPolygon as well, mirroring B2DPolyPolygon, plus adapting the insert() func to make use of that (avoiding loads of temporaries)
Diffstat (limited to 'basegfx/source/polygon')
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx19
-rw-r--r--basegfx/source/polygon/b3dpolypolygon.cxx71
2 files changed, 56 insertions, 34 deletions
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index e9bbb97c1234..3bc0401e271e 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -1628,25 +1628,6 @@ namespace basegfx
}
}
- const B2DPoint* B2DPolygon::begin() const
- {
- return mpPolygon->begin();
- }
-
- const B2DPoint* B2DPolygon::end() const
- {
- return mpPolygon->end();
- }
-
- B2DPoint* B2DPolygon::begin()
- {
- return mpPolygon->begin();
- }
-
- B2DPoint* B2DPolygon::end()
- {
- return mpPolygon->end();
- }
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/polygon/b3dpolypolygon.cxx b/basegfx/source/polygon/b3dpolypolygon.cxx
index 3bdd9c30340d..cbd59b6ac362 100644
--- a/basegfx/source/polygon/b3dpolypolygon.cxx
+++ b/basegfx/source/polygon/b3dpolypolygon.cxx
@@ -90,21 +90,10 @@ public:
void insert(sal_uInt32 nIndex, const ::basegfx::B3DPolyPolygon& rPolyPolygon)
{
- const sal_uInt32 nCount = rPolyPolygon.count();
-
- if(nCount)
- {
- // add nCount polygons from rPolyPolygon
- maPolygons.reserve(maPolygons.size() + nCount);
- PolygonVector::iterator aIndex(maPolygons.begin());
- aIndex += nIndex;
-
- for(sal_uInt32 a(0L); a < nCount; a++)
- {
- maPolygons.insert(aIndex, rPolyPolygon.getB3DPolygon(a));
- aIndex++;
- }
- }
+ // add all polygons from rPolyPolygon
+ PolygonVector::iterator aIndex(maPolygons.begin());
+ aIndex += nIndex;
+ maPolygons.insert(aIndex, rPolyPolygon.begin(), rPolyPolygon.end());
}
void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
@@ -201,6 +190,38 @@ public:
maPolygons.end(),
std::mem_fun_ref( &::basegfx::B3DPolygon::makeUnique ));
}
+
+ const basegfx::B3DPolygon* begin() const
+ {
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &maPolygons.front();
+ }
+
+ const basegfx::B3DPolygon* end() const
+ {
+ if(maPolygons.empty())
+ return 0;
+ else
+ return (&maPolygons.back())+1;
+ }
+
+ basegfx::B3DPolygon* begin()
+ {
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &maPolygons.front();
+ }
+
+ basegfx::B3DPolygon* end()
+ {
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &(maPolygons.back())+1;
+ }
};
//////////////////////////////////////////////////////////////////////////////
@@ -440,6 +461,26 @@ namespace basegfx
mpPolyPolygon->transform(rMatrix);
}
}
+
+ const B3DPolygon* B3DPolyPolygon::begin() const
+ {
+ return mpPolyPolygon->begin();
+ }
+
+ const B3DPolygon* B3DPolyPolygon::end() const
+ {
+ return mpPolyPolygon->end();
+ }
+
+ B3DPolygon* B3DPolyPolygon::begin()
+ {
+ return mpPolyPolygon->begin();
+ }
+
+ B3DPolygon* B3DPolyPolygon::end()
+ {
+ return mpPolyPolygon->end();
+ }
} // end of namespace basegfx
// eof