X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbook.cpp;h=1dd5aa6dadb4675cec1be733b3fb5380cdaab8cf;hp=98e9e155b4330341996872979930a50743e89e49;hb=8751b18cf0b5ddb9d7549a465444d5ace215a097;hpb=67338e6f322b8f8ec0d897815e16a87937efc9b0 diff --git a/src/book.cpp b/src/book.cpp index 98e9e155..1dd5aa6d 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -383,7 +383,7 @@ bool Book::open(const char* fName) { return false; // Silently fail if the file is not found // Get the book size in number of entries, we are already at the end of file - size = tellg() / sizeof(BookEntry); + size = (size_t)tellg() / sizeof(BookEntry); if (!good()) { @@ -458,30 +458,30 @@ Move Book::probe(const Position& pos, const string& fName, bool pickBest) { void Book::binary_search(uint64_t key) { - size_t left, right, mid; + size_t low, high, mid; BookEntry e; - left = 0; - right = size - 1; + low = 0; + high = size - 1; - assert(left <= right); + assert(low <= high); - while (left < right && good()) + while (low < high && good()) { - mid = (left + right) / 2; + mid = (low + high) / 2; - assert(mid >= left && mid < right); + assert(mid >= low && mid < high); seekg(mid * sizeof(BookEntry), ios_base::beg); *this >> e; if (key <= e.key) - right = mid; + high = mid; else - left = mid + 1; + low = mid + 1; } - assert(left == right); + assert(low == high); - seekg(left * sizeof(BookEntry), ios_base::beg); + seekg(low * sizeof(BookEntry), ios_base::beg); }