]> git.sesse.net Git - stockfish/commitdiff
Use pre-increment also for native types
authorKojirion <kojirion@tursh.com>
Sun, 15 Sep 2013 07:11:29 +0000 (09:11 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 15 Sep 2013 07:17:21 +0000 (09:17 +0200)
Now that we use pre-increment on enums, it
make sense, for code style uniformity, to
swith to pre-increment also for native types,
although there is no speed difference.

No functional change.

src/benchmark.cpp
src/bitboard.cpp
src/book.cpp
src/evaluate.cpp
src/main.cpp
src/movepick.cpp
src/position.cpp
src/rkiss.h
src/search.cpp
src/timeman.cpp
src/tt.cpp

index f22ea6dada5d2ca7246039d45454c9e5e7e01a63..a0dab27bbbf85479254a530549fa48793fc4185a 100644 (file)
@@ -116,7 +116,7 @@ void benchmark(const Position& current, istream& is) {
   Search::StateStackPtr st;
   Time::point elapsed = Time::now();
 
   Search::StateStackPtr st;
   Time::point elapsed = Time::now();
 
-  for (size_t i = 0; i < fens.size(); i++)
+  for (size_t i = 0; i < fens.size(); ++i)
   {
       Position pos(fens[i], Options["UCI_Chess960"], Threads.main());
 
   {
       Position pos(fens[i], Options["UCI_Chess960"], Threads.main());
 
index a377703b5b170dbbed3b99ab07892516fe639cc1..cbece63c43d6bd7ac3938ac8bb3c986323fc99cb 100644 (file)
@@ -150,11 +150,11 @@ void Bitboards::print(Bitboard b) {
 
 void Bitboards::init() {
 
 
 void Bitboards::init() {
 
-  for (int k = 0, i = 0; i < 8; i++)
+  for (int k = 0, i = 0; i < 8; ++i)
       while (k < (2 << i))
           MS1BTable[k++] = i;
 
       while (k < (2 << i))
           MS1BTable[k++] = i;
 
-  for (int i = 0; i < 64; i++)
+  for (int i = 0; i < 64; ++i)
       BSFTable[bsf_index(1ULL << i)] = Square(i);
 
   for (Square s = SQ_A1; s <= SQ_H8; ++s)
       BSFTable[bsf_index(1ULL << i)] = Square(i);
 
   for (Square s = SQ_A1; s <= SQ_H8; ++s)
@@ -163,7 +163,7 @@ void Bitboards::init() {
   FileBB[FILE_A] = FileABB;
   RankBB[RANK_1] = Rank1BB;
 
   FileBB[FILE_A] = FileABB;
   RankBB[RANK_1] = Rank1BB;
 
-  for (int i = 1; i < 8; i++)
+  for (int i = 1; i < 8; ++i)
   {
       FileBB[i] = FileBB[i - 1] << 1;
       RankBB[i] = RankBB[i - 1] << 8;
   {
       FileBB[i] = FileBB[i - 1] << 1;
       RankBB[i] = RankBB[i - 1] << 8;
@@ -235,7 +235,7 @@ namespace {
 
     Bitboard attack = 0;
 
 
     Bitboard attack = 0;
 
-    for (int i = 0; i < 4; i++)
+    for (int i = 0; i < 4; ++i)
         for (Square s = sq + deltas[i];
              is_ok(s) && square_distance(s, s - deltas[i]) == 1;
              s += deltas[i])
         for (Square s = sq + deltas[i];
              is_ok(s) && square_distance(s, s - deltas[i]) == 1;
              s += deltas[i])
@@ -322,7 +322,7 @@ namespace {
             // looks up the correct sliding attack in the attacks[s] database.
             // Note that we build up the database for square 's' as a side
             // effect of verifying the magic.
             // looks up the correct sliding attack in the attacks[s] database.
             // Note that we build up the database for square 's' as a side
             // effect of verifying the magic.
-            for (i = 0; i < size; i++)
+            for (i = 0; i < size; ++i)
             {
                 Bitboard& attack = attacks[s][index(s, occupancy[i])];
 
             {
                 Bitboard& attack = attacks[s][index(s, occupancy[i])];
 
index caf2b0663ec76987720231e29360c6d434238d27..c5c40dde42f1546a4a8e6938ecc1a19c6190a983 100644 (file)
@@ -361,7 +361,7 @@ PolyglotBook::~PolyglotBook() { if (is_open()) close(); }
 template<typename T> PolyglotBook& PolyglotBook::operator>>(T& n) {
 
   n = 0;
 template<typename T> PolyglotBook& PolyglotBook::operator>>(T& n) {
 
   n = 0;
-  for (size_t i = 0; i < sizeof(T); i++)
+  for (size_t i = 0; i < sizeof(T); ++i)
       n = T((n << 8) + ifstream::get());
 
   return *this;
       n = T((n << 8) + ifstream::get());
 
   return *this;
index 912c05fc8b394942e46a864235dd9c29dda5d8e0..fbde9d115cd8287485d235ff0d0caa296e8ded4e 100644 (file)
@@ -288,7 +288,7 @@ namespace Eval {
     const int MaxSlope = 30;
     const int Peak = 1280;
 
     const int MaxSlope = 30;
     const int Peak = 1280;
 
-    for (int t = 0, i = 1; i < 100; i++)
+    for (int t = 0, i = 1; i < 100; ++i)
     {
         t = std::min(Peak, std::min(int(0.4 * i * i), t + MaxSlope));
 
     {
         t = std::min(Peak, std::min(int(0.4 * i * i), t + MaxSlope));
 
index 3d26b63ac663e0f40e874c1cb75313d99ab191a4..74483a87ed29d010132007b4c2beabeec40023e5 100644 (file)
@@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
 
   std::string args;
 
 
   std::string args;
 
-  for (int i = 1; i < argc; i++)
+  for (int i = 1; i < argc; ++i)
       args += std::string(argv[i]) + " ";
 
   UCI::loop(args);
       args += std::string(argv[i]) + " ";
 
   UCI::loop(args);
index 4f2fa01eb231ba64e10feaba33d1af33977a35be..643c8368ca4cf1c28cbf4baa447aa88b5eb0248e 100644 (file)
@@ -231,7 +231,7 @@ void MovePicker::generate_next() {
       killers[2].move = killers[3].move = MOVE_NONE;
 
       // Be sure countermoves are different from killers
       killers[2].move = killers[3].move = MOVE_NONE;
 
       // Be sure countermoves are different from killers
-      for (int i = 0; i < 2; i++)
+      for (int i = 0; i < 2; ++i)
           if (countermoves[i] != cur->move && countermoves[i] != (cur+1)->move)
               (end++)->move = countermoves[i];
 
           if (countermoves[i] != cur->move && countermoves[i] != (cur+1)->move)
               (end++)->move = countermoves[i];
 
index 2266f2a573dfa05e313b0913d903578d1e4ebb2d..4cb7e3063be940f54e919607a760d949b1130317 100644 (file)
@@ -1149,7 +1149,7 @@ void Position::clear() {
   startState.epSquare = SQ_NONE;
   st = &startState;
 
   startState.epSquare = SQ_NONE;
   st = &startState;
 
-  for (int i = 0; i < PIECE_TYPE_NB; i++)
+  for (int i = 0; i < PIECE_TYPE_NB; ++i)
       for (int j = 0; j < 16; j++)
           pieceList[WHITE][i][j] = pieceList[BLACK][i][j] = SQ_NONE;
 }
       for (int j = 0; j < 16; j++)
           pieceList[WHITE][i][j] = pieceList[BLACK][i][j] = SQ_NONE;
 }
@@ -1428,7 +1428,7 @@ bool Position::pos_is_ok(int* failedStep) const {
   if ((*step)++, debugPieceList)
       for (Color c = WHITE; c <= BLACK; ++c)
           for (PieceType pt = PAWN; pt <= KING; ++pt)
   if ((*step)++, debugPieceList)
       for (Color c = WHITE; c <= BLACK; ++c)
           for (PieceType pt = PAWN; pt <= KING; ++pt)
-              for (int i = 0; i < pieceCount[c][pt]; i++)
+              for (int i = 0; i < pieceCount[c][pt];  ++i)
                   if (   board[pieceList[c][pt][i]] != make_piece(c, pt)
                       || index[pieceList[c][pt][i]] != i)
                       return false;
                   if (   board[pieceList[c][pt][i]] != make_piece(c, pt)
                       || index[pieceList[c][pt][i]] != i)
                       return false;
index 9564253b91a81301a70fd029163eac470248187c..18c1d4f69dacc8480b0894ae9de1829e5ef6a772 100644 (file)
@@ -64,7 +64,7 @@ public:
 
     s.a = 0xf1ea5eed;
     s.b = s.c = s.d = 0xd4e12c77;
 
     s.a = 0xf1ea5eed;
     s.b = s.c = s.d = 0xd4e12c77;
-    for (int i = 0; i < seed; i++) // Scramble a few rounds
+    for (int i = 0; i < seed; ++i) // Scramble a few rounds
         rand64();
   }
 
         rand64();
   }
 
index e29f54498e1ce3bfd322b493fc73e641a8c3d873..4ab17fd85ae80d82273841ffc08296763631f019 100644 (file)
@@ -236,7 +236,7 @@ void Search::think() {
   }
 
   // Reset the threads, still sleeping: will be wake up at split time
   }
 
   // Reset the threads, still sleeping: will be wake up at split time
-  for (size_t i = 0; i < Threads.size(); i++)
+  for (size_t i = 0; i < Threads.size(); ++i)
       Threads[i]->maxPly = 0;
 
   Threads.sleepWhileIdle = Options["Idle Threads Sleep"];
       Threads[i]->maxPly = 0;
 
   Threads.sleepWhileIdle = Options["Idle Threads Sleep"];
@@ -337,7 +337,7 @@ namespace {
 
         // Save last iteration's scores before first PV line is searched and all
         // the move scores but the (new) PV are set to -VALUE_INFINITE.
 
         // Save last iteration's scores before first PV line is searched and all
         // the move scores but the (new) PV are set to -VALUE_INFINITE.
-        for (size_t i = 0; i < RootMoves.size(); i++)
+        for (size_t i = 0; i < RootMoves.size(); ++i)
             RootMoves[i].prevScore = RootMoves[i].score;
 
         // MultiPV loop. We perform a full root search for each PV line
             RootMoves[i].prevScore = RootMoves[i].score;
 
         // MultiPV loop. We perform a full root search for each PV line
@@ -367,7 +367,7 @@ namespace {
 
                 // Write PV back to transposition table in case the relevant
                 // entries have been overwritten during the search.
 
                 // Write PV back to transposition table in case the relevant
                 // entries have been overwritten during the search.
-                for (size_t i = 0; i <= PVIdx; i++)
+                for (size_t i = 0; i <= PVIdx; ++i)
                     RootMoves[i].insert_pv_in_tt(pos);
 
                 // If search has been stopped return immediately. Sorting and
                     RootMoves[i].insert_pv_in_tt(pos);
 
                 // If search has been stopped return immediately. Sorting and
@@ -1102,7 +1102,7 @@ moves_loop: // When in check and at SpNode search starts from here
         // played non-capture moves.
         Value bonus = Value(int(depth) * int(depth));
         History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
         // played non-capture moves.
         Value bonus = Value(int(depth) * int(depth));
         History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
-        for (int i = 0; i < quietCount - 1; i++)
+        for (int i = 0; i < quietCount - 1; ++i)
         {
             Move m = quietsSearched[i];
             History.update(pos.piece_moved(m), to_sq(m), -bonus);
         {
             Move m = quietsSearched[i];
             History.update(pos.piece_moved(m), to_sq(m), -bonus);
@@ -1456,7 +1456,7 @@ moves_loop: // When in check and at SpNode search starts from here
     // Choose best move. For each move score we add two terms both dependent on
     // weakness, one deterministic and bigger for weaker moves, and one random,
     // then we choose the move with the resulting highest score.
     // Choose best move. For each move score we add two terms both dependent on
     // weakness, one deterministic and bigger for weaker moves, and one random,
     // then we choose the move with the resulting highest score.
-    for (size_t i = 0; i < PVSize; i++)
+    for (size_t i = 0; i < PVSize; ++i)
     {
         int s = RootMoves[i].score;
 
     {
         int s = RootMoves[i].score;
 
@@ -1489,11 +1489,11 @@ moves_loop: // When in check and at SpNode search starts from here
     size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size());
     int selDepth = 0;
 
     size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size());
     int selDepth = 0;
 
-    for (size_t i = 0; i < Threads.size(); i++)
+    for (size_t i = 0; i < Threads.size(); ++i)
         if (Threads[i]->maxPly > selDepth)
             selDepth = Threads[i]->maxPly;
 
         if (Threads[i]->maxPly > selDepth)
             selDepth = Threads[i]->maxPly;
 
-    for (size_t i = 0; i < uciPVSize; i++)
+    for (size_t i = 0; i < uciPVSize; ++i)
     {
         bool updated = (i <= PVIdx);
 
     {
         bool updated = (i <= PVIdx);
 
@@ -1730,7 +1730,7 @@ void check_time() {
 
       // Loop across all split points and sum accumulated SplitPoint nodes plus
       // all the currently active positions nodes.
 
       // Loop across all split points and sum accumulated SplitPoint nodes plus
       // all the currently active positions nodes.
-      for (size_t i = 0; i < Threads.size(); i++)
+      for (size_t i = 0; i < Threads.size(); ++i)
           for (int j = 0; j < Threads[i]->splitPointsSize; j++)
           {
               SplitPoint& sp = Threads[i]->splitPoints[j];
           for (int j = 0; j < Threads[i]->splitPointsSize; j++)
           {
               SplitPoint& sp = Threads[i]->splitPoints[j];
index 3bc9a317d6aabfc8c31f720360b5312ddc2181a8..8bda4f25abca4b667dbf08cbef6e5832855af632 100644 (file)
@@ -155,7 +155,7 @@ namespace {
     int thisMoveImportance = move_importance(currentPly) * slowMover / 100;
     int otherMovesImportance = 0;
 
     int thisMoveImportance = move_importance(currentPly) * slowMover / 100;
     int otherMovesImportance = 0;
 
-    for (int i = 1; i < movesToGo; i++)
+    for (int i = 1; i < movesToGo; ++i)
         otherMovesImportance += move_importance(currentPly + 2 * i);
 
     float ratio1 = (TMaxRatio * thisMoveImportance) / float(TMaxRatio * thisMoveImportance + otherMovesImportance);
         otherMovesImportance += move_importance(currentPly + 2 * i);
 
     float ratio1 = (TMaxRatio * thisMoveImportance) / float(TMaxRatio * thisMoveImportance + otherMovesImportance);
index 9774a2332fa8fd481983ee90b729195ec7112aeb..11173e0a1243511e24618f82a4def19a67f925dd 100644 (file)
@@ -73,7 +73,7 @@ const TTEntry* TranspositionTable::probe(const Key key) const {
   const TTEntry* tte = first_entry(key);
   uint32_t key32 = key >> 32;
 
   const TTEntry* tte = first_entry(key);
   uint32_t key32 = key >> 32;
 
-  for (unsigned i = 0; i < ClusterSize; i++, tte++)
+  for (unsigned i = 0; i < ClusterSize; ++i, tte++)
       if (tte->key() == key32)
           return tte;
 
       if (tte->key() == key32)
           return tte;
 
@@ -97,7 +97,7 @@ void TranspositionTable::store(const Key key, Value v, Bound b, Depth d, Move m,
 
   tte = replace = first_entry(key);
 
 
   tte = replace = first_entry(key);
 
-  for (unsigned i = 0; i < ClusterSize; i++, tte++)
+  for (unsigned i = 0; i < ClusterSize; ++i, tte++)
   {
       if (!tte->key() || tte->key() == key32) // Empty or overwrite old
       {
   {
       if (!tte->key() || tte->key() == key32) // Empty or overwrite old
       {