update: Reorder sector production for speed
The update visits sectors in increasing order of country number. Within a country, it visits in increasing order of sector number, which is effectively top to bottom, left to right, starting with absolute 0,0. The order doesn't actually matter. Before Chainsaw's option BUDGET, the update simply visited the sectors in sector number order. Go back to that order, because it's faster. For the update, it's a few percent in my testing. For budget, it's more than a third. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
c5df505c98
commit
5a548c9901
12 changed files with 132 additions and 127 deletions
|
@ -225,9 +225,10 @@ decay_fallout(struct sctstr *sp, int etus)
|
|||
* Produce for a specific nation
|
||||
*/
|
||||
void
|
||||
produce_sect(struct natstr *np, int etu, struct bp *bp)
|
||||
produce_sect(int etu, struct bp *bp)
|
||||
{
|
||||
struct budget *budget = &nat_budget[np->nat_cnum];
|
||||
struct budget *budget;
|
||||
struct natstr *np;
|
||||
struct sctstr *sp, scratch_sect;
|
||||
int n;
|
||||
double cost;
|
||||
|
@ -235,11 +236,6 @@ produce_sect(struct natstr *np, int etu, struct bp *bp)
|
|||
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
||||
if (sp->sct_type == SCT_WATER || sp->sct_type == SCT_SANCT)
|
||||
continue;
|
||||
if (sp->sct_own != np->nat_cnum)
|
||||
continue;
|
||||
if (sp->sct_updated != 0)
|
||||
continue;
|
||||
sp->sct_updated = 1;
|
||||
|
||||
/*
|
||||
* When running the test suite, reseed PRNG for each sector
|
||||
|
@ -256,6 +252,9 @@ produce_sect(struct natstr *np, int etu, struct bp *bp)
|
|||
sp = &scratch_sect;
|
||||
}
|
||||
|
||||
budget = &nat_budget[sp->sct_own];
|
||||
np = getnatp(sp->sct_own);
|
||||
|
||||
do_feed(sp, np, etu, 0);
|
||||
|
||||
if (dchr[sp->sct_type].d_maint) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue