Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Avoid allocations in
TrapezoidBounds::inside
(acts-project#3705)
Looking at some flame graphs I spotted some allocations in `TrapezoidBounds::inside` which should not be necessary. It does not look like it had a big impact. Apart from that I decided to replace the generic template argument for `insidePolygon` with a span. --- This pull request includes several changes to the `Acts` library, focusing on improving the handling of vertex data by using `std::span` and enhancing the boundary check logic. The most important changes include the introduction of `std::span` for vertex containers, the addition of necessary includes, and the modification of boundary check methods to use `std::span`. ### Improvements to vertex handling: * [`Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp`](diffhunk://#diff-afebd1f0fa546e69aed4734d1011f475e9ece065b5529419c7031fc64a2e5aa6L75-R77): Changed the `insidePolygon` function to use `std::span<const Vector2>` for vertex containers. * [`Core/include/Acts/Surfaces/detail/VerticesHelper.hpp`](diffhunk://#diff-575a21d724214109cec5c36d8f8fc9884ee879564b9f887b481e4cc08c3b294aL177-R179): Modified the `computeClosestPointOnPolygon` function to use `std::span<const Vector2>` for vertex containers. ### Inclusion of necessary headers: * [`Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp`](diffhunk://#diff-afebd1f0fa546e69aed4734d1011f475e9ece065b5529419c7031fc64a2e5aa6R13-R14): Added the `#include <span>` directive. * [`Core/include/Acts/Surfaces/detail/VerticesHelper.hpp`](diffhunk://#diff-575a21d724214109cec5c36d8f8fc9884ee879564b9f887b481e4cc08c3b294aR16): Added the `#include <span>` directive. * [`Core/src/Surfaces/DiamondBounds.cpp`](diffhunk://#diff-602202d907779fe1a0701875345ed35bb225e2431186cb09e845fb622ce259b4R11): Added the `#include "Acts/Definitions/Algebra.hpp"` directive. ### Boundary check logic enhancements: * [`Core/src/Surfaces/DiamondBounds.cpp`](diffhunk://#diff-602202d907779fe1a0701875345ed35bb225e2431186cb09e845fb622ce259b4L25-R36): Updated the `inside` method to use an array of `Vector2` for vertices and the `insidePolygon` function. * [`Core/src/Surfaces/TrapezoidBounds.cpp`](diffhunk://#diff-0db048c0e724a9a5dc84f75e864ddb1f21dac518388c5a51de11a0d72cfd8ce2L92-R92): Changed the vertices container from `std::vector` to an array of `Vector2` in the `inside` method.
- Loading branch information