Codechange: Use std::initializer_list/array in framerate window. (#12441)

This commit is contained in:
Peter Nelson 2024-04-19 22:07:56 +01:00 committed by GitHub
parent a28ab8cac2
commit f267b37a33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 6 deletions

View File

@ -810,7 +810,7 @@ struct FrametimeGraphWindow : Window {
/* Determine horizontal scale based on period covered by 60 points
* (slightly less than 2 seconds at full game speed) */
struct ScaleDef { TimingMeasurement range; int scale; };
static const ScaleDef hscales[] = {
static const std::initializer_list<ScaleDef> hscales = {
{ TIMESTAMP_PRECISION * 120, 60 },
{ TIMESTAMP_PRECISION * 10, 20 },
{ TIMESTAMP_PRECISION * 5, 10 },
@ -825,7 +825,7 @@ struct FrametimeGraphWindow : Window {
void SelectVerticalScale(TimingMeasurement range)
{
/* Determine vertical scale based on peak value (within the horizontal scale + a bit) */
static const TimingMeasurement vscales[] = {
static const std::initializer_list<TimingMeasurement> vscales = {
TIMESTAMP_PRECISION * 100,
TIMESTAMP_PRECISION * 10,
TIMESTAMP_PRECISION * 5,
@ -1048,7 +1048,7 @@ void ConPrintFramerate()
IConsolePrint(TC_SILVER, "Based on num. data points: {} {} {}", count1, count2, count3);
static const char *MEASUREMENT_NAMES[PFE_MAX] = {
static const std::array<std::string_view, PFE_MAX> MEASUREMENT_NAMES = {
"Game loop",
" GL station ticks",
" GL train ticks",
@ -1066,11 +1066,9 @@ void ConPrintFramerate()
};
std::string ai_name_buf;
static const PerformanceElement rate_elements[] = { PFE_GAMELOOP, PFE_DRAWING, PFE_VIDEO };
bool printed_anything = false;
for (const auto &e : rate_elements) {
for (const auto &e : { PFE_GAMELOOP, PFE_DRAWING, PFE_VIDEO }) {
auto &pf = _pf_data[e];
if (pf.num_valid == 0) continue;
IConsolePrint(TC_GREEN, "{} rate: {:.2f}fps (expected: {:.2f}fps)",