1
0
Fork 0

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.
sf_dd_base
Kojirion 2013-09-15 09:11:29 +02:00 committed by Marco Costalba
parent 7a1ff6d8ff
commit a71209868b
11 changed files with 24 additions and 24 deletions

View File

@ -116,7 +116,7 @@ void benchmark(const Position& current, istream& is) {
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());

View File

@ -150,11 +150,11 @@ void Bitboards::print(Bitboard b) {
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;
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)
@ -163,7 +163,7 @@ void Bitboards::init() {
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;
@ -235,7 +235,7 @@ namespace {
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])
@ -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.
for (i = 0; i < size; i++)
for (i = 0; i < size; ++i)
{
Bitboard& attack = attacks[s][index(s, occupancy[i])];

View File

@ -361,7 +361,7 @@ PolyglotBook::~PolyglotBook() { if (is_open()) close(); }
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;

View File

@ -288,7 +288,7 @@ namespace Eval {
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));

View File

@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
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);

View File

@ -231,7 +231,7 @@ void MovePicker::generate_next() {
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];

View File

@ -1149,7 +1149,7 @@ void Position::clear() {
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;
}
@ -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)
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;

View File

@ -64,7 +64,7 @@ public:
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();
}

View File

@ -236,7 +236,7 @@ void Search::think() {
}
// 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"];
@ -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.
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
@ -367,7 +367,7 @@ namespace {
// 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
@ -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);
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);
@ -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.
for (size_t i = 0; i < PVSize; i++)
for (size_t i = 0; i < PVSize; ++i)
{
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;
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;
for (size_t i = 0; i < uciPVSize; i++)
for (size_t i = 0; i < uciPVSize; ++i)
{
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.
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];

View File

@ -155,7 +155,7 @@ namespace {
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);

View File

@ -73,7 +73,7 @@ const TTEntry* TranspositionTable::probe(const Key key) const {
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;
@ -97,7 +97,7 @@ void TranspositionTable::store(const Key key, Value v, Bound b, Depth d, Move m,
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
{