a_select is not fast, so we try to avoid it

This commit is contained in:
Enno Rehling 2006-02-26 11:09:00 +00:00
parent 318f348f27
commit 5c474b9eb7
1 changed files with 16 additions and 5 deletions

View File

@ -268,8 +268,8 @@ ct_find(const char *c)
*/ */
typedef struct cid { typedef struct cid {
int id; int id;
int id2; int id2;
} twoids; } twoids;
boolean boolean
@ -324,10 +324,21 @@ get_cursex(attrib *ap, const curse_type * ctype, variant data, boolean(*compare)
curse * curse *
get_curse(attrib *ap, const curse_type * ctype) get_curse(attrib *ap, const curse_type * ctype)
{ {
attrib * a = a_select(ap, ctype, cmp_cursetype); attrib * a = ap;
while (a) {
if (a->type->flags & ATF_CURSE) {
const attrib_type * at = a->type;
while (a && a->type==at) {
curse* c = (curse *)a->data.v;
if (c->type==ctype) return c;
a = a->next;
}
} else {
a = a->nexttype;
}
}
if (!a) return NULL; return NULL;
return (curse*)a->data.v;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */