update: Drop redundant bp map updates and functions
produce_sect() updates the bp map several times. This is wasteful: since only ship, plane and land unit building reads it, bp map writes before the last one are never read. Update it just once for every sector. The update for sectors that are stopped or whose owner is broke is the only remaining use of bp_put_items(). Since available work must still be unchanged there, we can replace it by bp_set_from_sect(). bp_get_item(), bp_put_item(), bp_get_items(), bp_get_avail() and bp_put_avail() are now unused. Drop them. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
199b1498c8
commit
5b0fd1171d
3 changed files with 8 additions and 64 deletions
|
@ -66,70 +66,21 @@ static enum bp_item_idx bud_key[I_MAX + 1] = {
|
|||
BP_LCM, BP_HCM, BP_NONE, BP_NONE
|
||||
};
|
||||
|
||||
/*
|
||||
* Return the item value tracked in @bp for sector @sp's item @comm.
|
||||
* @comm must be a tracked item type.
|
||||
*/
|
||||
int
|
||||
bp_get_item(struct bp *bp, struct sctstr *sp, i_type comm)
|
||||
{
|
||||
enum bp_item_idx idx = bud_key[comm];
|
||||
|
||||
if (CANT_HAPPEN(idx < 0) || !bp)
|
||||
return sp->sct_item[comm];
|
||||
return bp[sp->sct_uid].bp_item[idx];
|
||||
}
|
||||
|
||||
/*
|
||||
* Set item value tracked in @bp for sector @sp's item @comm to @amount.
|
||||
*/
|
||||
/* Set the values tracked in @bp for sector @sp to the values in @sp. */
|
||||
void
|
||||
bp_put_item(struct bp *bp, struct sctstr *sp, i_type comm, int amount)
|
||||
bp_set_from_sect(struct bp *bp, struct sctstr *sp)
|
||||
{
|
||||
enum bp_item_idx idx = bud_key[comm];
|
||||
|
||||
if (bp && idx >= 0)
|
||||
bp[sp->sct_uid].bp_item[idx] = amount;
|
||||
}
|
||||
|
||||
/* Set the item values tracked in @bp from sector @sp. */
|
||||
void
|
||||
bp_put_items(struct bp *bp, struct sctstr *sp)
|
||||
{
|
||||
enum bp_item_idx idx;
|
||||
i_type i;
|
||||
enum bp_item_idx idx;
|
||||
|
||||
if (!bp)
|
||||
return;
|
||||
|
||||
for (i = I_NONE + 1; i <= I_MAX; i++) {
|
||||
idx = bud_key[i];
|
||||
if (idx >= 0)
|
||||
bp[sp->sct_uid].bp_item[idx] = sp->sct_item[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Return avail tracked in @bp for sector @sp. */
|
||||
int
|
||||
bp_get_avail(struct bp *bp, struct sctstr *sp)
|
||||
{
|
||||
return bp ? bp[sp->sct_uid].bp_avail : sp->sct_avail;
|
||||
}
|
||||
|
||||
/* Set avail tracked in @bp for sector @sp to @amount. */
|
||||
void
|
||||
bp_put_avail(struct bp *bp, struct sctstr *sp, int amount)
|
||||
{
|
||||
if (bp)
|
||||
bp[sp->sct_uid].bp_avail = amount;
|
||||
}
|
||||
|
||||
/* Set the values tracked in @bp for sector @sp to the values in @sp. */
|
||||
void
|
||||
bp_set_from_sect(struct bp *bp, struct sctstr *sp)
|
||||
{
|
||||
bp_put_items(bp, sp);
|
||||
bp_put_avail(bp, sp, sp->sct_avail);
|
||||
bp[sp->sct_uid].bp_avail = sp->sct_avail;
|
||||
}
|
||||
|
||||
/* Copy the values tracked in @bp for sector @sp back to @sp. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue