Micro-optimize king evaluation
authorMarco Costalba <mcostalba@gmail.com>
Sat, 28 Apr 2012 09:37:55 +0000 (10:37 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 28 Apr 2012 09:37:55 +0000 (10:37 +0100)
Reuse already calculated value, instead of calling
king_safety() again.

Patch suggested by Balint Pfliegel.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/evaluate.cpp

index 6f6141bafd37e0c3f0701376cd47f8a85523e107..4865910e917b3c0d2237490a7aec4244e6bd5efe 100644 (file)
@@ -775,7 +775,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
         attackUnits =  std::min(25, (ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) / 2)
                      + 3 * (ei.kingAdjacentZoneAttacksCount[Them] + popcount<Max15>(undefended))
                      + InitKingDanger[relative_square(Us, ksq)]
-                     - mg_value(ei.pi->king_safety<Us>(pos, ksq)) / 32;
+                     - mg_value(score) / 32;
 
         // Analyse enemy's safe queen contact checks. First find undefended
         // squares around the king attacked by enemy queen...