(svn r17735) -Codechange: update the cache one inserting/removing CargoPackets from the CargoList via Append/Truncate instead of rebuilding the whole cache. For Append this changes the O(n) cache rebuild into a O(1) cache update. For Truncate no temporary list is needed anymore (based on patch by fonsinchen)

This commit is contained in:
rubidium
2009-10-07 08:25:12 +00:00
parent 446363aac4
commit 705615fd91
2 changed files with 55 additions and 25 deletions

View File

@@ -169,6 +169,20 @@ private:
List packets; ///< The cargo packets in this list
/**
* Update the cache to reflect adding of this packet.
* Increases count, feeder share and days_in_transit
* @param cp a new packet to be inserted
*/
void AddToCache(const CargoPacket *cp);
/**
* Update the cached values to reflect the removal of this packet.
* Decreases count, feeder share and days_in_transit
* @param cp Packet to be removed from cache
*/
void RemoveFromCache(const CargoPacket *cp);
public:
/** The stations, via GoodsEntry, have a CargoList. */
friend const struct SaveLoad *GetGoodsDesc();