From f5816a6d7726c5f9d0c2cd32b1934b02d4ee3cd9 Mon Sep 17 00:00:00 2001 From: ferreo Date: Thu, 21 Nov 2024 11:01:55 +0100 Subject: [PATCH] Update debian/patches/0001-Bezier-Opti.patch --- debian/patches/0001-Bezier-Opti.patch | 29 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/debian/patches/0001-Bezier-Opti.patch b/debian/patches/0001-Bezier-Opti.patch index 6ee272a..b03fafb 100644 --- a/debian/patches/0001-Bezier-Opti.patch +++ b/debian/patches/0001-Bezier-Opti.patch @@ -1,4 +1,4 @@ -From 3b7208caffa1362e43eff57d58b86d38e484193b Mon Sep 17 00:00:00 2001 +From a5fff93908a78740c17a7e5edccc01ad0edda5c5 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Tue, 19 Nov 2024 18:46:03 +0100 Subject: [PATCH] bezier: optimize setup of bezier curves @@ -15,15 +15,15 @@ references where we can. these changes we are now down to an average of "time to bake: 2.50µs." on my machine compared to before average of "time to bake: 11.15µs" --- - src/helpers/BezierCurve.cpp | 35 ++++++++++++++++++++--------------- + src/helpers/BezierCurve.cpp | 39 ++++++++++++++++++++++++------------- src/helpers/BezierCurve.hpp | 8 ++++---- - 2 files changed, 24 insertions(+), 19 deletions(-) + 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/helpers/BezierCurve.cpp b/src/helpers/BezierCurve.cpp -index ea567ad61ca..0ef0883f805 100644 +index ea567ad61ca..23fcd691f24 100644 --- a/src/helpers/BezierCurve.cpp +++ b/src/helpers/BezierCurve.cpp -@@ -6,24 +6,21 @@ +@@ -6,24 +6,27 @@ #include void CBezierCurve::setup(std::vector* pVec) { @@ -35,13 +35,18 @@ index ea567ad61ca..0ef0883f805 100644 - - for (auto const& p : *pVec) { - m_dPoints.push_back(p); -- } -- -- m_dPoints.emplace_back(Vector2D(1, 1)); + // Avoid reallocations by reserving enough memory upfront + m_dPoints.resize(pVec->size() + 2); + m_dPoints[0] = Vector2D(0, 0); // Start point -+ std::copy(pVec->begin(), pVec->end(), m_dPoints.begin() + 1); ++ size_t index = 1; // Start after the first element ++ for (const auto& vec : *pVec) { ++ if (index < m_dPoints.size() - 1) { // Bounds check to ensure safety ++ m_dPoints[index] = vec; ++ ++index; ++ } + } +- +- m_dPoints.emplace_back(Vector2D(1, 1)); + m_dPoints.back() = Vector2D(1, 1); // End point RASSERT(m_dPoints.size() == 4, "CBezierCurve only supports cubic beziers! (points num: {})", m_dPoints.size()); @@ -55,7 +60,7 @@ index ea567ad61ca..0ef0883f805 100644 } const auto ELAPSEDUS = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - BEGIN).count() / 1000.f; -@@ -40,18 +37,26 @@ void CBezierCurve::setup(std::vector* pVec) { +@@ -40,18 +43,26 @@ void CBezierCurve::setup(std::vector* pVec) { ELAPSEDUS, ELAPSEDCALCAVG); } @@ -109,5 +114,5 @@ index 54af46a6b0f..1a842f5a833 100644 std::array m_aPointsBaked; }; - - + + \ No newline at end of file