summaryrefslogtreecommitdiff
path: root/src/cargopacket.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-07 08:25:12 +0000
committerrubidium <rubidium@openttd.org>2009-10-07 08:25:12 +0000
commit705615fd914c51daacf4adb2aed9e21e6698e755 (patch)
tree3c4a711a5402700f16ace7ad4addc7b2e25502a5 /src/cargopacket.h
parent446363aac4c791cf39254c3da7f1bc34e2aebf57 (diff)
downloadopenttd-705615fd914c51daacf4adb2aed9e21e6698e755.tar.xz
(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)
Diffstat (limited to 'src/cargopacket.h')
-rw-r--r--src/cargopacket.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cargopacket.h b/src/cargopacket.h
index bbad42bff..9d8251550 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -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();