From 830c9e2de84ee6edfa5cacbd8ef8777de1156ed8 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 5 Apr 2024 19:31:08 +0100 Subject: [PATCH] Codechange: Simplify iteration of framerate performance elements. --- src/framerate_gui.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 7e32bd611b..dc5698791d 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -817,8 +817,8 @@ struct FrametimeGraphWindow : Window { { TIMESTAMP_PRECISION * 3, 4 }, { TIMESTAMP_PRECISION * 1, 2 }, }; - for (const ScaleDef *sc = hscales; sc < hscales + lengthof(hscales); sc++) { - if (range < sc->range) this->horizontal_scale = sc->scale; + for (const auto &sc : hscales) { + if (range < sc.range) this->horizontal_scale = sc.scale; } } @@ -836,8 +836,8 @@ struct FrametimeGraphWindow : Window { TIMESTAMP_PRECISION / 50, TIMESTAMP_PRECISION / 200, }; - for (const TimingMeasurement *sc = vscales; sc < vscales + lengthof(vscales); sc++) { - if (range < *sc) this->vertical_scale = (int)*sc; + for (const auto &sc : vscales) { + if (range < sc) this->vertical_scale = (int)sc; } } @@ -1070,11 +1070,11 @@ void ConPrintFramerate() bool printed_anything = false; - for (const PerformanceElement *e = rate_elements; e < rate_elements + lengthof(rate_elements); e++) { - auto &pf = _pf_data[*e]; + for (const auto &e : rate_elements) { + auto &pf = _pf_data[e]; if (pf.num_valid == 0) continue; IConsolePrint(TC_GREEN, "{} rate: {:.2f}fps (expected: {:.2f}fps)", - MEASUREMENT_NAMES[*e], + MEASUREMENT_NAMES[e], pf.GetRate(), pf.expected_rate); printed_anything = true;