mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Avoid a needless locking in sp_search()
Only in less then 2% of cases we have a new sp->bestValue, so check before to lock and save a costly locking most of the times. Patch suggested by Joona. No functional search. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -1759,6 +1759,8 @@ namespace {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// New best move?
|
// New best move?
|
||||||
|
if (value > sp->bestValue) // Less then 2% of cases
|
||||||
|
{
|
||||||
lock_grab(&(sp->lock));
|
lock_grab(&(sp->lock));
|
||||||
if (value > sp->bestValue && !thread_should_stop(threadID))
|
if (value > sp->bestValue && !thread_should_stop(threadID))
|
||||||
{
|
{
|
||||||
@@ -1775,6 +1777,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
lock_release(&(sp->lock));
|
lock_release(&(sp->lock));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lock_grab(&(sp->lock));
|
lock_grab(&(sp->lock));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user