Apply clang-tidy recommendations

This commit is contained in:
Michael Davidson 2023-12-30 10:53:31 +11:00
parent 2f3b4a25b2
commit 38ac72c912
No known key found for this signature in database
GPG key ID: B8D1A99712B8B0EB
2 changed files with 8 additions and 8 deletions

View file

@ -41,7 +41,7 @@ display::Rect TextRunPanel::measure_item_internal(display::Display *display) {
void TextRunPanel::render_internal(display::Display *display, display::Rect bounds) { void TextRunPanel::render_internal(display::Display *display, display::Rect bounds) {
CalculatedLayout layout = this->determine_layout(display, bounds, true); 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) { if (calculated->run->background_color_ != display::COLOR_OFF) {
display->filled_rectangle(calculated->bounds.x, calculated->bounds.y, calculated->bounds.w, calculated->bounds.h, display->filled_rectangle(calculated->bounds.x, calculated->bounds.y, calculated->bounds.w, calculated->bounds.h,
calculated->run->background_color_); calculated->run->background_color_);
@ -52,7 +52,7 @@ void TextRunPanel::render_internal(display::Display *display, display::Rect boun
if (this->debug_outline_runs_) { if (this->debug_outline_runs_) {
ESP_LOGD(TAG, "Outlining character 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); 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<std::shared_ptr<CalculatedTextRun>> line_runs; std::vector<std::shared_ptr<CalculatedTextRun>> line_runs;
// Get all the runs for the current line // 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) { if (run->line_number_ == i) {
line_runs.push_back(run); 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, 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 x_adjustment = 0;
int y_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; 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, 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, run->bounds.y + y_adjustment);
run->bounds.x += x_adjustment; run->bounds.x += x_adjustment;

View file

@ -21,7 +21,7 @@ struct CanWrapAtCharacterArguments {
CanWrapAtCharacterArguments(const TextRunPanel *panel, int offset, std::string string, char character) { CanWrapAtCharacterArguments(const TextRunPanel *panel, int offset, std::string string, char character) {
this->panel = panel; this->panel = panel;
this->offset = offset; this->offset = offset;
this->string = string; this->string = std::move(string);
this->character = character; this->character = character;
} }
@ -34,7 +34,7 @@ struct CanWrapAtCharacterArguments {
class TextRun { class TextRun {
public: public:
TextRun(TemplatableValue<std::string> text, display::BaseFont *font) { TextRun(TemplatableValue<std::string> text, display::BaseFont *font) {
this->text_ = text; this->text_ = std::move(text);
this->font_ = font; this->font_ = font;
} }
@ -51,7 +51,7 @@ class CalculatedTextRun {
public: public:
CalculatedTextRun(TextRun *run, std::string text, display::Rect bounds, int16_t baseline, int16_t line_number) { CalculatedTextRun(TextRun *run, std::string text, display::Rect bounds, int16_t baseline, int16_t line_number) {
this->run = run; this->run = run;
this->text_ = text; this->text_ = std::move(text);
this->bounds = bounds; this->bounds = bounds;
this->baseline = baseline; this->baseline = baseline;
this->line_number_ = line_number; this->line_number_ = line_number;