mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 01:56:58 +08:00
Microptimize MoveList loop
Add MOVE_NONE at the tail, this allows to loop across MoveList checking for *it != MOVE_NONE, and because *it is used imediately after compiler is able to reuse it. With this small patch perft speed increased of 3% And it is also a semplification ! No functional change.
This commit is contained in:
@@ -41,10 +41,9 @@ MoveStack* generate(const Position& pos, MoveStack* mlist);
|
||||
template<GenType T>
|
||||
struct MoveList {
|
||||
|
||||
explicit MoveList(const Position& pos) : cur(mlist), last(generate<T>(pos, mlist)) {}
|
||||
explicit MoveList(const Position& pos) : cur(mlist), last(generate<T>(pos, mlist)) { last->move = MOVE_NONE; }
|
||||
void operator++() { cur++; }
|
||||
Move operator*() const { return cur->move; }
|
||||
bool end() const { return cur == last; }
|
||||
size_t size() const { return last - mlist; }
|
||||
bool contains(Move m) const {
|
||||
for (const MoveStack* it(mlist); it != last; ++it) if (it->move == m) return true;
|
||||
|
||||
Reference in New Issue
Block a user