Bessere Zuornung der Aufrufe von lastregion und firstregion, für den Profiler

This commit is contained in:
Enno Rehling 2004-02-21 12:19:50 +00:00
parent 6ccb1b9bf6
commit 325dd3d2cc
4 changed files with 34 additions and 28 deletions

View file

@ -172,9 +172,9 @@ improve_all(faction * f, skill_t sk, int weeks)
region *r;
unit *u;
int n = 0;
region *last = lastregion(f);
region *last = f->last?f->last:lastregion(f);
for (r = firstregion(f); r != last; r = r->next) {
for (r = f->first?f->first:firstregion(f); r != last; r = r->next) {
for (u = r->units; u; u = u->next) {
if (u->faction == f && has_skill(u, sk)) {
for (n=0;n!=weeks;++n) {

View file

@ -1556,7 +1556,7 @@ order_template(FILE * F, faction * f)
plane *pl;
unit *u;
int dh;
region *last = lastregion(f);
region *last = f->last?f->last:lastregion(f);
rps_nowrap(F, "");
rnl(F);
@ -1579,7 +1579,7 @@ order_template(FILE * F, faction * f)
rps_nowrap(F, buf);
rnl(F);
for (r = firstregion(f); r != last; r = r->next) {
for (r = f->first?f->first:firstregion(f); r != last; r = r->next) {
dh = 0;
for (u = r->units; u; u = u->next)
if (u->faction == f && u->race != new_race[RC_SPELL]) {
@ -1963,7 +1963,7 @@ report(FILE *F, faction * f, const faction_list * addresses,
int dh;
int anyunits;
const struct region *r;
region * last = lastregion(f);
region * last = f->last?f->last:lastregion(f);
building *b;
ship *sh;
unit *u;
@ -2203,7 +2203,7 @@ report(FILE *F, faction * f, const faction_list * addresses,
anyunits = 0;
for (r=firstregion(f);r!=last;r=r->next) {
for (r=f->first?f->first:firstregion(f);r!=last;r=r->next) {
boolean unit_in_region = false;
boolean durchgezogen_in_region = false;
int turm_sieht_region = false;
@ -2797,9 +2797,9 @@ static void
prepare_report(faction * f)
{
region * r;
region * end = lastregion(f);
region * end = f->last?f->last:lastregion(f);
seen_init();
for (r = firstregion(f); r != end; r = r->next) {
for (r = f->first?f->first:firstregion(f); r != end; r = r->next) {
attrib *ru;
unit * u;
plane * p = rplane(r);

View file

@ -442,13 +442,15 @@ count_skill(faction * f, skill_t sk)
int n = 0;
region *r;
unit *u;
region *last = lastregion(f);
region *last = f->last?f->last:lastregion(f);
for (r = firstregion(f); r != last; r = r->next)
for (u = r->units; u; u = u->next)
if (u->faction == f && has_skill(u, sk))
for (r =f->first?f->first:firstregion(f); r != last; r = r->next) {
for (u = r->units; u; u = u->next) {
if (u->faction == f && has_skill(u, sk)) {
if (!is_familiar(u)) n += u->number;
}
}
}
return n;
}

View file

@ -856,12 +856,13 @@ visible_faction(const faction *f, const unit * u)
faction_list *
get_addresses(faction * f)
{
#if 0
/* "TODO: travelthru" */
region *r, *last = lastregion(f);
region *r, *last = f->last?f->last:lastregion(f);
const faction * lastf = NULL;
faction_list * flist = calloc(1, sizeof(faction_list));
flist->data = findfaction(f->no);
for (r=firstregion(f);r!=last;r=r->next) {
for (r=f->first?f->first:firstregion(f);r!=last;r=r->next) {
const unit * u = r->units;
const seen_region * sr = find_seen(r);
if (sr==NULL) continue;
@ -905,4 +906,7 @@ get_addresses(faction * f)
}
#endif
return flist;
#else
return NULL;
#endif
}