From ab65fda4c29fd955094909d570b3a66daf1bf647 Mon Sep 17 00:00:00 2001 From: j0ta29 Date: Fri, 27 Dec 2024 21:22:05 +0000 Subject: [PATCH] fixed new clang-tidy issue --- esphome/components/optolink/helpers.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/optolink/helpers.cpp b/esphome/components/optolink/helpers.cpp index 08e4c03f5d..bc1b779a7f 100644 --- a/esphome/components/optolink/helpers.cpp +++ b/esphome/components/optolink/helpers.cpp @@ -3,6 +3,7 @@ #include "helpers.h" #include "esphome/core/log.h" #include +#include namespace esphome { namespace optolink { @@ -14,10 +15,9 @@ void rtrim(std::string &s) { return; std::string::iterator p; - for (p = s.end(); p != s.begin() && *--p == ' ';) - ; + p = std::find_if(s.rbegin(), s.rend(), [](char ch) { return ch != ' '; }).base(); - if (*p != ' ') + if (p != s.begin() && *p != ' ') p++; s.erase(p, s.end());