Simplify array initializations

also retire a few std::memset calls.

Passed non-regresion STC:
https://tests.stockfishchess.org/tests/view/65b8e162c865510db0276901
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 97504 W: 25294 L: 25140 D: 47070
Ptnml(1-2): 378, 11102, 25667, 11198, 407

closes https://github.com/official-stockfish/Stockfish/pull/5018

No functional change
This commit is contained in:
Disservin
2024-01-27 10:54:44 +01:00
committed by Joost VandeVondele
parent fcbb02ffde
commit 13eb023fc0
3 changed files with 31 additions and 30 deletions

View File

@@ -19,6 +19,7 @@
#include "position.h"
#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <cstddef>
@@ -107,9 +108,8 @@ inline int H1(Key h) { return h & 0x1fff; }
inline int H2(Key h) { return (h >> 16) & 0x1fff; }
// Cuckoo tables with Zobrist hashes of valid reversible moves, and the moves themselves
Key cuckoo[8192];
Move cuckooMove[8192];
std::array<Key, 8192> cuckoo;
std::array<Move, 8192> cuckooMove;
// Initializes at startup the various arrays used to compute hash keys
void Position::init() {
@@ -130,8 +130,8 @@ void Position::init() {
Zobrist::noPawns = rng.rand<Key>();
// Prepare the cuckoo tables
std::memset(cuckoo, 0, sizeof(cuckoo));
std::memset(cuckooMove, 0, sizeof(cuckooMove));
cuckoo.fill(0);
cuckooMove.fill(Move::none());
[[maybe_unused]] int count = 0;
for (Piece pc : Pieces)
for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)