forked from mirror/OpenTTD
(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:
@@ -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();
|
||||
|
Reference in New Issue
Block a user