]> git.sesse.net Git - stockfish/blobdiff - src/pawns.cpp
Assorted code style and comments in search.cpp
[stockfish] / src / pawns.cpp
index ef225847776eb593757e376de49824ceb6e2a60d..6fc2f2feb9479cf631366c6d03ca5afad5971999 100644 (file)
@@ -81,27 +81,6 @@ namespace {
 //// Functions
 ////
 
-/// PawnInfoTable c'tor and d'tor instantiated one each thread
-
-PawnInfoTable::PawnInfoTable() {
-
-  entries = new PawnInfo[PawnTableSize];
-
-  if (!entries)
-  {
-      std::cerr << "Failed to allocate " << (PawnTableSize * sizeof(PawnInfo))
-                << " bytes for pawn hash table." << std::endl;
-      Application::exit_with_failure();
-  }
-  memset(entries, 0, PawnTableSize * sizeof(PawnInfo));
-}
-
-
-PawnInfoTable::~PawnInfoTable() {
-
-  delete [] entries;
-}
-
 
 /// PawnInfoTable::get_pawn_info() takes a position object as input, computes
 /// a PawnInfo object, and returns a pointer to it. The result is also stored
@@ -113,8 +92,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) const {
   assert(pos.is_ok());
 
   Key key = pos.get_pawn_key();
-  unsigned index = unsigned(key & (PawnTableSize - 1));
-  PawnInfo* pi = entries + index;
+  PawnInfo* pi = find(key);
 
   // If pi->key matches the position's pawn hash key, it means that we
   // have analysed this pawn structure before, and we can simply return
@@ -158,7 +136,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns,
   // Loop through all pawns of the current color and score each pawn
   while ((s = *ptr++) != SQ_NONE)
   {
-      assert(pos.piece_on(s) == piece_of_color_and_type(Us, PAWN));
+      assert(pos.piece_on(s) == make_piece(Us, PAWN));
 
       f = square_file(s);
       r = square_rank(s);