From ce7848f7cc4a7f7eecdcc58a68cf424ec0fcaf1c Mon Sep 17 00:00:00 2001 From: FauziAkram Date: Sun, 19 Apr 2026 07:23:21 +0200 Subject: [PATCH] Remove the Redundant ply Variables in Benchmark Calculations In setup_benchmark, the variables evaluating the current ply simply mirror the exact iterative progress of the string arrays loop (since ply just increments by 1 with every pass). We can delete the separate integer assignment and execute it securely within the loop declaration. closes https://github.com/official-stockfish/Stockfish/pull/6732 No functional change --- src/benchmark.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/benchmark.cpp b/src/benchmark.cpp index 03bf10ae1..6c1a7d28f 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -483,15 +483,8 @@ BenchmarkSetup setup_benchmark(std::istream& is) { float totalTime = 0; for (const auto& game : BenchmarkPositions) - { - int ply = 1; - for (int i = 0; i < static_cast(game.size()); ++i) - { - const float correctedTime = float(getCorrectedTime(ply)); - totalTime += correctedTime; - ply += 1; - } - } + for (size_t i = 0; i < game.size(); ++i) + totalTime += float(getCorrectedTime(i + 1)); float timeScaleFactor = static_cast(desiredTimeS * 1000) / totalTime; @@ -502,11 +495,8 @@ BenchmarkSetup setup_benchmark(std::istream& is) { for (const std::string& fen : game) { setup.commands.emplace_back("position fen " + fen); - - const int correctedTime = static_cast(getCorrectedTime(ply) * timeScaleFactor); + const int correctedTime = static_cast(getCorrectedTime(ply++) * timeScaleFactor); setup.commands.emplace_back("go movetime " + std::to_string(correctedTime)); - - ply += 1; } }