optimization: no need to look for a curse if unit has no attribs.

This commit is contained in:
Enno Rehling 2016-08-29 19:41:21 +01:00
parent 40d9ebfa94
commit 8ff26eb0e4
2 changed files with 16 additions and 19 deletions

View File

@ -1463,8 +1463,6 @@ static void make_route(unit * u, order * ord, region_list ** routep)
static int movement_speed(unit * u)
{
int mp = BP_WALKING;
static const curse_type *speed_ct;
static bool init = false;
double dk = u_race(u)->speed;
assert(u->number);
@ -1482,10 +1480,8 @@ static int movement_speed(unit * u)
break;
}
if (!init) {
init = true;
speed_ct = ct_find("speed");
}
if (u->attribs) {
const curse_type *speed_ct = ct_find("speed");
if (speed_ct) {
curse *c = get_curse(u->attribs, speed_ct);
if (c != NULL) {
@ -1493,6 +1489,7 @@ static int movement_speed(unit * u)
dk *= 1.0 + (double)men / (double)u->number;
}
}
}
switch (canride(u)) {
case 1: /* Pferd */

View File

@ -270,19 +270,19 @@ report_items(const unit *u, item * result, int size, const unit * owner,
{
const item *itm, *items = u->items;
int n = 0; /* number of results */
bool itemcloak = false;
const curse_type *itemcloak_ct = ct_find("itemcloak");
assert(owner == NULL || viewer != owner->faction);
assert(size);
if (u->attribs) {
const curse_type *itemcloak_ct = ct_find("itemcloak");
if (itemcloak_ct) {
curse * cu = get_curse(u->attribs, itemcloak_ct);
itemcloak = cu && curse_active(cu);
}
if (itemcloak) {
if (cu && curse_active(cu)) {
return 0;
}
}
}
for (itm = items; itm; itm = itm->next) {
item *ishow;
const char *ic;