From 38462627dbc2f18e9e70e884f960c1b0952729c5 Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:16:34 +0000 Subject: [PATCH] Codechange: 3 steps of std::min/max with 2 elements are faster than 1 single step with 4 --- src/tile_map.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/tile_map.cpp b/src/tile_map.cpp index 54cfc8ebd2..aaec4b8755 100644 --- a/src/tile_map.cpp +++ b/src/tile_map.cpp @@ -120,12 +120,14 @@ int GetTileZ(TileIndex tile) uint x2 = std::min(x1 + 1, Map::MaxX()); uint y2 = std::min(y1 + 1, Map::MaxY()); - return std::min({ - TileHeight(tile), // N corner - TileHeight(TileXY(x2, y1)), // W corner - TileHeight(TileXY(x1, y2)), // E corner - TileHeight(TileXY(x2, y2)), // S corner - }); + return std::min( + std::min( + TileHeight(tile), // N corner + TileHeight(TileXY(x2, y1))), // W corner + std::min( + TileHeight(TileXY(x1, y2)), // E corner + TileHeight(TileXY(x2, y2))) // S corner + ); } /** @@ -140,10 +142,12 @@ int GetTileMaxZ(TileIndex t) uint x2 = std::min(x1 + 1, Map::MaxX()); uint y2 = std::min(y1 + 1, Map::MaxY()); - return std::max({ - TileHeight(t), // N corner - TileHeight(TileXY(x2, y1)), // W corner - TileHeight(TileXY(x1, y2)), // E corner - TileHeight(TileXY(x2, y2)), // S corner - }); + return std::max( + std::max( + TileHeight(t), // N corner + TileHeight(TileXY(x2, y1))), // W corner + std::max( + TileHeight(TileXY(x1, y2)), // E corner + TileHeight(TileXY(x2, y2))) // S corner + ); }