Use emplace_back() in TB code
authorSebastian Buchwald <Sebastian.Buchwald@kit.edu>
Thu, 22 Nov 2018 22:50:03 +0000 (23:50 +0100)
committerStéphane Nicolet <cassio@free.fr>
Thu, 29 Nov 2018 14:01:54 +0000 (15:01 +0100)
The patch was tested for correctness by running bench with and
without the change against current master, and the tablebase hit
numbers were found to be identical in both cases. See the pull
request comments for details:
https://github.com/official-stockfish/Stockfish/pull/1826

No functional change.

src/syzygy/tbprobe.cpp
src/tt.cpp

index 8f1ac15f9431b735615d44db5300911ae9fc34b2..d0b59f056a9c02119c7ca3ce94e3c6a7dd1341bd 100644 (file)
@@ -1277,7 +1277,7 @@ void Tablebases::init(const std::string& paths) {
                         continue; // First on diagonal, second above
 
                     else if (!off_A1H8(s1) && !off_A1H8(s2))
-                        bothOnDiagonal.push_back(std::make_pair(idx, s2));
+                        bothOnDiagonal.emplace_back(idx, s2);
 
                     else
                         MapKK[idx][s2] = code++;
index 53e78595045548bed917e75132dfc084c60ed88a..716d13e0695b9c108ba142879c365f573e027a73 100644 (file)
@@ -84,7 +84,7 @@ void TranspositionTable::clear() {
 
   for (size_t idx = 0; idx < Options["Threads"]; idx++)
   {
-      threads.push_back(std::thread([this, idx]() {
+      threads.emplace_back([this, idx]() {
 
           // Thread binding gives faster search on systems with a first-touch policy
           if (Options["Threads"] > 8)
@@ -97,7 +97,7 @@ void TranspositionTable::clear() {
                                 stride : clusterCount - start;
 
           std::memset(&table[start], 0, len * sizeof(Cluster));
-      }));
+      });
   }
 
   for (std::thread& th: threads)