From 2576f781d4d8d5783bac39f457d64007d18c9c60 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 4 Mar 2007 18:46:01 +0000 Subject: [PATCH] validation code for FASTROW optimization --- src/common/kernel/battle.c | 10 +++++++--- src/common/kernel/battle.h | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index b1299d977..a63fcdcb6 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -479,9 +479,7 @@ get_unitrow(const fighter * af, const side * vs) } else { #ifdef FASTROW battle * b = vs->battle; - if (row==b->rowcache.row && b->alive==b->rowcache.alive && af->side==b->rowcache.as && vs==b->rowcache.vs) { - return b->rowcache.result; - } else { + if (row!=b->rowcache.row || b->alive!=b->rowcache.alive || af->side!=b->rowcache.as || vs!=b->rowcache.vs) { b->rowcache.alive = b->alive; b->rowcache.as = af->side; b->rowcache.vs = vs; @@ -489,6 +487,12 @@ get_unitrow(const fighter * af, const side * vs) b->rowcache.result = get_row(af->side, row, vs); return b->rowcache.result; } +#if 1 /* validation code */ + { + int i = get_row(af->side, row, vs); + assert(i==b->rowcache.result); + } +#endif return b->rowcache.result; #else return get_row(af->side, row, vs); diff --git a/src/common/kernel/battle.h b/src/common/kernel/battle.h index 58ba67177..389ec4195 100644 --- a/src/common/kernel/battle.h +++ b/src/common/kernel/battle.h @@ -70,7 +70,7 @@ extern "C" { #ifdef SMALL_BATTLE_MESSAGES boolean small; #endif -#undef FASTROW +#define FASTROW #ifdef FASTROW struct { const struct side * as; @@ -80,7 +80,7 @@ extern "C" { int result; } rowcache; #endif -#undef FASTCOUNT +#define FASTCOUNT #ifdef FASTCOUNT struct { struct side * side;