From bdb586ac2b9b5cbbb3e42a8af13035b008403b72 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 25 Jul 2009 16:16:28 +0100 Subject: [PATCH] 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 --- src/search.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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) { -- 2.39.2