diff --git a/esphome/components/graphical_layout/text_run_panel.cpp b/esphome/components/graphical_layout/text_run_panel.cpp index 6378517223..d1c9ba5960 100644 --- a/esphome/components/graphical_layout/text_run_panel.cpp +++ b/esphome/components/graphical_layout/text_run_panel.cpp @@ -41,7 +41,7 @@ display::Rect TextRunPanel::measure_item_internal(display::Display *display) { void TextRunPanel::render_internal(display::Display *display, display::Rect bounds) { CalculatedLayout layout = this->determine_layout(display, bounds, true); - for (auto calculated : layout.runs) { + for (const auto& calculated : layout.runs) { if (calculated->run->background_color_ != display::COLOR_OFF) { display->filled_rectangle(calculated->bounds.x, calculated->bounds.y, calculated->bounds.w, calculated->bounds.h, calculated->run->background_color_); @@ -52,7 +52,7 @@ void TextRunPanel::render_internal(display::Display *display, display::Rect boun if (this->debug_outline_runs_) { ESP_LOGD(TAG, "Outlining character runs"); - for (auto calculated : layout.runs) { + for (const auto& calculated : layout.runs) { display->rectangle(calculated->bounds.x, calculated->bounds.y, calculated->bounds.w, calculated->bounds.h); } } @@ -185,7 +185,7 @@ void TextRunPanel::apply_alignment_to_layout(CalculatedLayout *calculated_layout std::vector> line_runs; // Get all the runs for the current line - for (auto run : calculated_layout->runs) { + for (const auto& run : calculated_layout->runs) { if (run->line_number_ == i) { line_runs.push_back(run); } @@ -203,7 +203,7 @@ void TextRunPanel::apply_alignment_to_layout(CalculatedLayout *calculated_layout } ESP_LOGVV(TAG, "Line %i totals (%i, %i) pixels of (%i, %i)", i, total_line_width, max_line_height, - calculated_layout->bounds.w, calculated_layout->bounds.h) + calculated_layout->bounds.w, calculated_layout->bounds.h); int x_adjustment = 0; int y_adjustment = 0; @@ -224,7 +224,7 @@ void TextRunPanel::apply_alignment_to_layout(CalculatedLayout *calculated_layout } int max_line_y_adjustment = 0; - for (auto run : line_runs) { + for (const auto& run : line_runs) { ESP_LOGVV(TAG, "Adjusting '%s' from (%i, %i) to (%i, %i)", run->text_.c_str(), run->bounds.x, run->bounds.y, run->bounds.x + x_adjustment, run->bounds.y + y_adjustment); run->bounds.x += x_adjustment; diff --git a/esphome/components/graphical_layout/text_run_panel.h b/esphome/components/graphical_layout/text_run_panel.h index c523d812b2..4a86ed4e1d 100644 --- a/esphome/components/graphical_layout/text_run_panel.h +++ b/esphome/components/graphical_layout/text_run_panel.h @@ -21,7 +21,7 @@ struct CanWrapAtCharacterArguments { CanWrapAtCharacterArguments(const TextRunPanel *panel, int offset, std::string string, char character) { this->panel = panel; this->offset = offset; - this->string = string; + this->string = std::move(string); this->character = character; } @@ -34,7 +34,7 @@ struct CanWrapAtCharacterArguments { class TextRun { public: TextRun(TemplatableValue text, display::BaseFont *font) { - this->text_ = text; + this->text_ = std::move(text); this->font_ = font; } @@ -51,7 +51,7 @@ class CalculatedTextRun { public: CalculatedTextRun(TextRun *run, std::string text, display::Rect bounds, int16_t baseline, int16_t line_number) { this->run = run; - this->text_ = text; + this->text_ = std::move(text); this->bounds = bounds; this->baseline = baseline; this->line_number_ = line_number;