From 05c080328b07451b6a2d73bda6b10ccad34cc782 Mon Sep 17 00:00:00 2001 From: Michael Lesirge <100492377+MichaelLesirge@users.noreply.github.com> Date: Fri, 13 Jun 2025 18:50:05 -0700 Subject: [PATCH] [wpimath] Pass Translation2d by const reference instead of by value (#8021) --- .../include/frc/geometry/Translation2d.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wpimath/src/main/native/include/frc/geometry/Translation2d.h b/wpimath/src/main/native/include/frc/geometry/Translation2d.h index aa6c4753ef..a859743988 100644 --- a/wpimath/src/main/native/include/frc/geometry/Translation2d.h +++ b/wpimath/src/main/native/include/frc/geometry/Translation2d.h @@ -238,10 +238,11 @@ class WPILIB_DLLEXPORT Translation2d { */ constexpr Translation2d Nearest( std::span translations) const { - return *std::min_element(translations.begin(), translations.end(), - [this](Translation2d a, Translation2d b) { - return this->Distance(a) < this->Distance(b); - }); + return *std::min_element( + translations.begin(), translations.end(), + [this](const Translation2d& a, const Translation2d& b) { + return this->Distance(a) < this->Distance(b); + }); } /** @@ -251,10 +252,11 @@ class WPILIB_DLLEXPORT Translation2d { */ constexpr Translation2d Nearest( std::initializer_list translations) const { - return *std::min_element(translations.begin(), translations.end(), - [this](Translation2d a, Translation2d b) { - return this->Distance(a) < this->Distance(b); - }); + return *std::min_element( + translations.begin(), translations.end(), + [this](const Translation2d& a, const Translation2d& b) { + return this->Distance(a) < this->Distance(b); + }); } private: