From: Marco Costalba Date: Sat, 25 Jul 2009 15:16:28 +0000 (+0100) Subject: Micro optimize extension() in search.cpp X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=bdb586ac2b9b5cbbb3e42a8af13035b008403b72 Micro optimize extension() in search.cpp Small micro-optimization in this very time critical function. Use bitwise 'or' instead of logic 'or' to avoid branches in the assembly and use the result to skip an handful of checks. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/search.cpp b/src/search.cpp index 75b6bd0c..fb308424 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -2202,16 +2202,19 @@ namespace { assert(m != MOVE_NONE); Depth result = Depth(0); - *dangerous = check || singleReply || mateThreat; + *dangerous = check | singleReply | mateThreat; - if (check) - result += CheckExtension[pvNode]; + if (*dangerous) + { + if (check) + result += CheckExtension[pvNode]; - if (singleReply) - result += SingleReplyExtension[pvNode]; + if (singleReply) + result += SingleReplyExtension[pvNode]; - if (mateThreat) - result += MateThreatExtension[pvNode]; + if (mateThreat) + result += MateThreatExtension[pvNode]; + } if (pos.type_of_piece_on(move_from(m)) == PAWN) {