From: Sebastian Buchwald Date: Fri, 6 Jan 2023 17:13:21 +0000 (+0100) Subject: Avoid unnecessary string copies X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=4f4e652ecaf8d42a9bd1092f72c3704435ddba12 Avoid unnecessary string copies closes https://github.com/official-stockfish/Stockfish/pull/4326 also fixes typo, closes https://github.com/official-stockfish/Stockfish/pull/4332 No functional change --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 3aae9f1c..6db977a4 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -89,7 +89,7 @@ namespace Eval { vector dirs = { "" , "" , CommandLine::binaryDirectory }; #endif - for (string directory : dirs) + for (const string& directory : dirs) if (currentEvalFileName != eval_file) { if (directory != "") diff --git a/src/nnue/layers/sqr_clipped_relu.h b/src/nnue/layers/sqr_clipped_relu.h index df539b39..3fbb243c 100644 --- a/src/nnue/layers/sqr_clipped_relu.h +++ b/src/nnue/layers/sqr_clipped_relu.h @@ -106,7 +106,7 @@ namespace Stockfish::Eval::NNUE::Layers { for (IndexType i = Start; i < InputDimensions; ++i) { output[i] = static_cast( - // realy should be /127 but we need to make it fast + // really should be /127 but we need to make it fast // needs to be accounted for in the trainer std::max(0ll, std::min(127ll, (((long long)input[i] * input[i]) >> (2 * WeightScaleBits)) / 128))); } diff --git a/src/uci.cpp b/src/uci.cpp index eb158e72..30c1fa0c 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -160,7 +160,7 @@ namespace { uint64_t num, nodes = 0, cnt = 1; vector list = setup_bench(pos, args); - num = count_if(list.begin(), list.end(), [](string s) { return s.find("go ") == 0 || s.find("eval") == 0; }); + num = count_if(list.begin(), list.end(), [](const string& s) { return s.find("go ") == 0 || s.find("eval") == 0; }); TimePoint elapsed = now();