From 889df64fbb9534491b76140d63b4340091c763e4 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 17 Aug 2021 13:39:03 +0200 Subject: [PATCH] reduce alloc costs for some basegfx objects (tdf#105575) we can use a default object for the default constructo case, and remove one malloc for each default constructed object Change-Id: I0bec37ef9161a210973abb25669a9f16a5e0ea75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120603 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basegfx/source/matrix/b2dhommatrix.cxx | 4 +++- basegfx/source/polygon/b2dpolypolygon.cxx | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index 89088e8ebdbf..badda594c9de 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -31,7 +31,9 @@ namespace basegfx { }; - B2DHomMatrix::B2DHomMatrix() = default; + static o3tl::cow_wrapper DEFAULT; + + B2DHomMatrix::B2DHomMatrix() : mpImpl(DEFAULT) {} B2DHomMatrix::B2DHomMatrix(const B2DHomMatrix&) = default; diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index dcd6133abc4a..36c221eeb106 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -200,7 +200,10 @@ public: namespace basegfx { - B2DPolyPolygon::B2DPolyPolygon() = default; + static o3tl::cow_wrapper DEFAULT; + + B2DPolyPolygon::B2DPolyPolygon() : + mpPolyPolygon(DEFAULT) {} B2DPolyPolygon::B2DPolyPolygon(const B2DPolyPolygon&) = default;