Skip to content

Commit a712098

Browse files
Kojirionmcostalba
authored andcommitted
Use pre-increment also for native types
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.
1 parent 7a1ff6d commit a712098

File tree

11 files changed

+24
-24
lines changed

11 files changed

+24
-24
lines changed

src/benchmark.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void benchmark(const Position& current, istream& is) {
116116
Search::StateStackPtr st;
117117
Time::point elapsed = Time::now();
118118

119-
for (size_t i = 0; i < fens.size(); i++)
119+
for (size_t i = 0; i < fens.size(); ++i)
120120
{
121121
Position pos(fens[i], Options["UCI_Chess960"], Threads.main());
122122

src/bitboard.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ void Bitboards::print(Bitboard b) {
150150

151151
void Bitboards::init() {
152152

153-
for (int k = 0, i = 0; i < 8; i++)
153+
for (int k = 0, i = 0; i < 8; ++i)
154154
while (k < (2 << i))
155155
MS1BTable[k++] = i;
156156

157-
for (int i = 0; i < 64; i++)
157+
for (int i = 0; i < 64; ++i)
158158
BSFTable[bsf_index(1ULL << i)] = Square(i);
159159

160160
for (Square s = SQ_A1; s <= SQ_H8; ++s)
@@ -163,7 +163,7 @@ void Bitboards::init() {
163163
FileBB[FILE_A] = FileABB;
164164
RankBB[RANK_1] = Rank1BB;
165165

166-
for (int i = 1; i < 8; i++)
166+
for (int i = 1; i < 8; ++i)
167167
{
168168
FileBB[i] = FileBB[i - 1] << 1;
169169
RankBB[i] = RankBB[i - 1] << 8;
@@ -235,7 +235,7 @@ namespace {
235235

236236
Bitboard attack = 0;
237237

238-
for (int i = 0; i < 4; i++)
238+
for (int i = 0; i < 4; ++i)
239239
for (Square s = sq + deltas[i];
240240
is_ok(s) && square_distance(s, s - deltas[i]) == 1;
241241
s += deltas[i])
@@ -322,7 +322,7 @@ namespace {
322322
// looks up the correct sliding attack in the attacks[s] database.
323323
// Note that we build up the database for square 's' as a side
324324
// effect of verifying the magic.
325-
for (i = 0; i < size; i++)
325+
for (i = 0; i < size; ++i)
326326
{
327327
Bitboard& attack = attacks[s][index(s, occupancy[i])];
328328

src/book.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ PolyglotBook::~PolyglotBook() { if (is_open()) close(); }
361361
template<typename T> PolyglotBook& PolyglotBook::operator>>(T& n) {
362362

363363
n = 0;
364-
for (size_t i = 0; i < sizeof(T); i++)
364+
for (size_t i = 0; i < sizeof(T); ++i)
365365
n = T((n << 8) + ifstream::get());
366366

367367
return *this;

src/evaluate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ namespace Eval {
288288
const int MaxSlope = 30;
289289
const int Peak = 1280;
290290

291-
for (int t = 0, i = 1; i < 100; i++)
291+
for (int t = 0, i = 1; i < 100; ++i)
292292
{
293293
t = std::min(Peak, std::min(int(0.4 * i * i), t + MaxSlope));
294294

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
4343

4444
std::string args;
4545

46-
for (int i = 1; i < argc; i++)
46+
for (int i = 1; i < argc; ++i)
4747
args += std::string(argv[i]) + " ";
4848

4949
UCI::loop(args);

src/movepick.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void MovePicker::generate_next() {
231231
killers[2].move = killers[3].move = MOVE_NONE;
232232

233233
// Be sure countermoves are different from killers
234-
for (int i = 0; i < 2; i++)
234+
for (int i = 0; i < 2; ++i)
235235
if (countermoves[i] != cur->move && countermoves[i] != (cur+1)->move)
236236
(end++)->move = countermoves[i];
237237

src/position.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ void Position::clear() {
11491149
startState.epSquare = SQ_NONE;
11501150
st = &startState;
11511151

1152-
for (int i = 0; i < PIECE_TYPE_NB; i++)
1152+
for (int i = 0; i < PIECE_TYPE_NB; ++i)
11531153
for (int j = 0; j < 16; j++)
11541154
pieceList[WHITE][i][j] = pieceList[BLACK][i][j] = SQ_NONE;
11551155
}
@@ -1428,7 +1428,7 @@ bool Position::pos_is_ok(int* failedStep) const {
14281428
if ((*step)++, debugPieceList)
14291429
for (Color c = WHITE; c <= BLACK; ++c)
14301430
for (PieceType pt = PAWN; pt <= KING; ++pt)
1431-
for (int i = 0; i < pieceCount[c][pt]; i++)
1431+
for (int i = 0; i < pieceCount[c][pt]; ++i)
14321432
if ( board[pieceList[c][pt][i]] != make_piece(c, pt)
14331433
|| index[pieceList[c][pt][i]] != i)
14341434
return false;

src/rkiss.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class RKISS {
6464

6565
s.a = 0xf1ea5eed;
6666
s.b = s.c = s.d = 0xd4e12c77;
67-
for (int i = 0; i < seed; i++) // Scramble a few rounds
67+
for (int i = 0; i < seed; ++i) // Scramble a few rounds
6868
rand64();
6969
}
7070

src/search.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void Search::think() {
236236
}
237237

238238
// Reset the threads, still sleeping: will be wake up at split time
239-
for (size_t i = 0; i < Threads.size(); i++)
239+
for (size_t i = 0; i < Threads.size(); ++i)
240240
Threads[i]->maxPly = 0;
241241

242242
Threads.sleepWhileIdle = Options["Idle Threads Sleep"];
@@ -337,7 +337,7 @@ namespace {
337337

338338
// Save last iteration's scores before first PV line is searched and all
339339
// the move scores but the (new) PV are set to -VALUE_INFINITE.
340-
for (size_t i = 0; i < RootMoves.size(); i++)
340+
for (size_t i = 0; i < RootMoves.size(); ++i)
341341
RootMoves[i].prevScore = RootMoves[i].score;
342342

343343
// MultiPV loop. We perform a full root search for each PV line
@@ -367,7 +367,7 @@ namespace {
367367

368368
// Write PV back to transposition table in case the relevant
369369
// entries have been overwritten during the search.
370-
for (size_t i = 0; i <= PVIdx; i++)
370+
for (size_t i = 0; i <= PVIdx; ++i)
371371
RootMoves[i].insert_pv_in_tt(pos);
372372

373373
// If search has been stopped return immediately. Sorting and
@@ -1102,7 +1102,7 @@ namespace {
11021102
// played non-capture moves.
11031103
Value bonus = Value(int(depth) * int(depth));
11041104
History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
1105-
for (int i = 0; i < quietCount - 1; i++)
1105+
for (int i = 0; i < quietCount - 1; ++i)
11061106
{
11071107
Move m = quietsSearched[i];
11081108
History.update(pos.piece_moved(m), to_sq(m), -bonus);
@@ -1456,7 +1456,7 @@ namespace {
14561456
// Choose best move. For each move score we add two terms both dependent on
14571457
// weakness, one deterministic and bigger for weaker moves, and one random,
14581458
// then we choose the move with the resulting highest score.
1459-
for (size_t i = 0; i < PVSize; i++)
1459+
for (size_t i = 0; i < PVSize; ++i)
14601460
{
14611461
int s = RootMoves[i].score;
14621462

@@ -1489,11 +1489,11 @@ namespace {
14891489
size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size());
14901490
int selDepth = 0;
14911491

1492-
for (size_t i = 0; i < Threads.size(); i++)
1492+
for (size_t i = 0; i < Threads.size(); ++i)
14931493
if (Threads[i]->maxPly > selDepth)
14941494
selDepth = Threads[i]->maxPly;
14951495

1496-
for (size_t i = 0; i < uciPVSize; i++)
1496+
for (size_t i = 0; i < uciPVSize; ++i)
14971497
{
14981498
bool updated = (i <= PVIdx);
14991499

@@ -1730,7 +1730,7 @@ void check_time() {
17301730

17311731
// Loop across all split points and sum accumulated SplitPoint nodes plus
17321732
// all the currently active positions nodes.
1733-
for (size_t i = 0; i < Threads.size(); i++)
1733+
for (size_t i = 0; i < Threads.size(); ++i)
17341734
for (int j = 0; j < Threads[i]->splitPointsSize; j++)
17351735
{
17361736
SplitPoint& sp = Threads[i]->splitPoints[j];

src/timeman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ namespace {
155155
int thisMoveImportance = move_importance(currentPly) * slowMover / 100;
156156
int otherMovesImportance = 0;
157157

158-
for (int i = 1; i < movesToGo; i++)
158+
for (int i = 1; i < movesToGo; ++i)
159159
otherMovesImportance += move_importance(currentPly + 2 * i);
160160

161161
float ratio1 = (TMaxRatio * thisMoveImportance) / float(TMaxRatio * thisMoveImportance + otherMovesImportance);

0 commit comments

Comments
 (0)