From 081cebb2f777d9ca8187599dd46bed37da88b429 Mon Sep 17 00:00:00 2001 From: Mounir Tohami <53877170+WhalesState@users.noreply.github.com> Date: Sat, 23 Aug 2025 03:46:20 +0300 Subject: [PATCH] Geometry2D minor optimization --- core/math/geometry_2d.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp index cbf77603949..5b07a0256e8 100644 --- a/core/math/geometry_2d.cpp +++ b/core/math/geometry_2d.cpp @@ -292,14 +292,16 @@ Vector> Geometry2D::_polypaths_do_operation(PolyBooleanOperation } Vector> polypaths; - for (PathsD::size_type i = 0; i < paths.size(); ++i) { + polypaths.resize(paths.size()); + for (PathsD::size_type i = 0; i < paths.size(); i++) { const PathD &path = paths[i]; Vector polypath; + polypath.resize(path.size()); for (PathsD::size_type j = 0; j < path.size(); ++j) { - polypath.push_back(Point2(static_cast(path[j].x), static_cast(path[j].y))); + polypath.set(j, Point2(static_cast(path[j].x), static_cast(path[j].y))); } - polypaths.push_back(polypath); + polypaths.set(i, polypath); } return polypaths; } @@ -353,14 +355,16 @@ Vector> Geometry2D::_polypath_offset(const Vector &p_poly // to attain the desired precision. Vector> polypaths; + polypaths.resize(paths.size()); for (PathsD::size_type i = 0; i < paths.size(); ++i) { const PathD &path = paths[i]; Vector polypath2; + polypath2.resize(path.size()); for (PathsD::size_type j = 0; j < path.size(); ++j) { - polypath2.push_back(Point2(static_cast(path[j].x), static_cast(path[j].y))); + polypath2.set(j, Point2(static_cast(path[j].x), static_cast(path[j].y))); } - polypaths.push_back(polypath2); + polypaths.set(i, polypath2); } return polypaths; }