From e276c812648bf511d6c4813d6fd82a00391cfdac Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 17 Oct 2019 20:33:50 +0200 Subject: size some stringbuffer to prevent re-alloc I started with 32 and kept doubling the size until the site did not need re-alloc, but clamped it at 512 (e.g. in emfio/). Change-Id: Ib7caf35a1b7e42b0e4ed8aa812493449e3eefc8f Reviewed-on: https://gerrit.libreoffice.org/81540 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basegfx/source/polygon/b2dsvgpolypolygon.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'basegfx/source') diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index 991e50bf60f0..2fdacad3653f 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -722,7 +722,14 @@ namespace basegfx bool bOOXMLMotionPath) { const sal_uInt32 nCount(rPolyPolygon.count()); - OUStringBuffer aResult; + sal_uInt32 nCombinedPointCount = 0; + for(sal_uInt32 i(0); i < nCount; i++) + { + const B2DPolygon& aPolygon(rPolyPolygon.getB2DPolygon(i)); + nCombinedPointCount += aPolygon.count(); + } + + OUStringBuffer aResult(std::max(nCombinedPointCount * 32,512)); B2DPoint aCurrentSVGPosition(0.0, 0.0); // SVG assumes (0,0) as the initial current point for(sal_uInt32 i(0); i < nCount; i++) -- cgit