From 043ff40d0255c680b504afb37c602fbaad24816b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 19 Sep 2016 18:28:44 +0200 Subject: [PATCH] eliminate another call to old_race. --- src/spells.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/spells.c b/src/spells.c index 37fa9af55..a860abe3c 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2731,21 +2731,23 @@ static int sp_firewall(castorder * co) */ static race *unholy_race(const race *rc) { - race *target_race = NULL; - switch (old_race(rc)) { - case RC_SKELETON: - target_race = get_race(RC_SKELETON_LORD); - break; - case RC_ZOMBIE: - target_race = get_race(RC_ZOMBIE_LORD); - break; - case RC_GHOUL: - target_race = get_race(RC_GHOUL_LORD); - break; - default: - target_race = NULL; + static int cache; + static race * rc_skeleton, *rc_zombie, *rc_ghoul; + if (rc_changed(&cache)) { + rc_skeleton = get_race(RC_SKELETON); + rc_zombie = get_race(RC_ZOMBIE); + rc_ghoul = get_race(RC_GHOUL); } - return target_race; + if (rc == rc_skeleton) { + return get_race(RC_SKELETON_LORD); + } + if (rc == rc_zombie) { + return get_race(RC_ZOMBIE_LORD); + } + if (rc == rc_ghoul) { + return get_race(RC_GHOUL_LORD); + } + return NULL; } static int sp_unholypower(castorder * co)