From 7eb6a488ade31254151fd516aa4c94fc56b84a1f Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 1 Apr 2012 12:26:14 +0100 Subject: [PATCH] Use a std::vector to store searchMoves A std::set (that is a rb_tree) seems really overkill to store at most a handful of moves and nothing in the common case. No functional change. Signed-off-by: Marco Costalba --- src/benchmark.cpp | 2 +- src/main.cpp | 2 +- src/thread.cpp | 4 ++-- src/thread.h | 3 +-- src/uci.cpp | 10 +++++----- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/benchmark.cpp b/src/benchmark.cpp index fbf5a46d..c31609bb 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -118,7 +118,7 @@ void benchmark(istringstream& is) { } else { - Threads.start_searching(pos, limits); + Threads.start_searching(pos, limits, vector()); Threads.wait_for_search_finished(); nodes += Search::RootPosition.nodes_searched(); } diff --git a/src/main.cpp b/src/main.cpp index 087f6dd6..6e889883 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,7 +46,7 @@ int main(int argc, char* argv[]) { std::string args; for (int i = 1; i < argc; i++) - args += std::string(" ") + argv[i]; + args += std::string(argv[i]) + " "; uci_loop(args); } diff --git a/src/thread.cpp b/src/thread.cpp index 2dcbf910..8d669880 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -429,7 +429,7 @@ void ThreadsManager::wait_for_search_finished() { // main_loop() so to start a new search, then returns immediately. void ThreadsManager::start_searching(const Position& pos, const LimitsType& limits, - const std::set& searchMoves) { + const std::vector& searchMoves) { wait_for_search_finished(); SearchTime.restart(); // As early as possible @@ -442,7 +442,7 @@ void ThreadsManager::start_searching(const Position& pos, const LimitsType& limi RootMoves.clear(); for (MoveList ml(pos); !ml.end(); ++ml) - if (searchMoves.empty() || searchMoves.count(ml.move())) + if (searchMoves.empty() || count(searchMoves.begin(), searchMoves.end(), ml.move())) RootMoves.push_back(RootMove(ml.move())); threads[0]->do_sleep = false; diff --git a/src/thread.h b/src/thread.h index 3d175483..fe2cf425 100644 --- a/src/thread.h +++ b/src/thread.h @@ -20,7 +20,6 @@ #if !defined(THREAD_H_INCLUDED) #define THREAD_H_INCLUDED -#include #include #include "material.h" @@ -126,7 +125,7 @@ public: void set_timer(int msec); void wait_for_search_finished(); void start_searching(const Position& pos, const Search::LimitsType& limits, - const std::set& = std::set()); + const std::vector& searchMoves); template Value split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value bestValue, Move* bestMove, diff --git a/src/uci.cpp b/src/uci.cpp index a2998e62..a10920a9 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -212,7 +212,7 @@ namespace { void go(Position& pos, istringstream& is) { Search::LimitsType limits; - std::set searchMoves; + vector searchMoves; string token; while (is >> token) @@ -239,7 +239,7 @@ namespace { limits.ponder = true; else if (token == "searchmoves") while (is >> token) - searchMoves.insert(move_from_uci(pos, token)); + searchMoves.push_back(move_from_uci(pos, token)); } Threads.start_searching(pos, limits, searchMoves); @@ -263,8 +263,8 @@ namespace { int e = time.elapsed(); - std::cout << "\nNodes " << n - << "\nTime (ms) " << e - << "\nNodes/second " << int(n / (e / 1000.0)) << std::endl; + cout << "\nNodes " << n + << "\nTime (ms) " << e + << "\nNodes/second " << int(n / (e / 1000.0)) << endl; } } -- 2.39.2