From 474b0314b356111cfa8f4a9cd63cd0d41d97c42d Mon Sep 17 00:00:00 2001 From: bofdahof <172177156+bofdahof@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:47:33 +1000 Subject: [PATCH] CAM: apply std::ranges --- .../CAM/PathSimulator/AppGL/MillSimulation.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.cpp b/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.cpp index 8e1269868b..a59adb12aa 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.cpp @@ -129,16 +129,17 @@ EndMill* MillSimulation::GetTool(int toolId) return nullptr; } -void MillSimulation::RemoveTool(int toolId) +void MillSimulation::RemoveTool(const int toolId) { - EndMill* tool; - if ((tool = GetTool(toolId)) != nullptr) { - auto it = std::find(mToolTable.begin(), mToolTable.end(), tool); - if (it != mToolTable.end()) { - mToolTable.erase(it); - } - delete tool; + EndMill* tool = GetTool(toolId); + if (tool == nullptr) { + return; } + + if (const auto it = std::ranges::find(mToolTable, tool); it != mToolTable.end()) { + mToolTable.erase(it); + } + delete tool; }