1
0
mirror of https://github.com/esphome/esphome.git synced 2025-01-18 20:10:55 +00:00

fixed new clang-tidy issue

This commit is contained in:
j0ta29 2024-12-27 21:22:05 +00:00
parent 62b8a77c49
commit ab65fda4c2

View File

@ -3,6 +3,7 @@
#include "helpers.h"
#include "esphome/core/log.h"
#include <cstring>
#include <algorithm>
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());