validation code for FASTROW optimization

This commit is contained in:
Enno Rehling 2007-03-04 18:46:01 +00:00
parent 373e869931
commit 2576f781d4
2 changed files with 9 additions and 5 deletions

View File

@ -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);

View File

@ -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;