changeset 13223:3708f1006de8 draft

(svn r17730) -Codechange: do not cache the source of a packet in the cargo list. It's only used for (some) GUI/NewGRF purposes so precalculating it costs more than calculating when it's actually used.
author rubidium <rubidium@openttd.org>
date Tue, 06 Oct 2009 21:06:26 +0000
parents ccca102feab4
children 194a605c55ab
files src/cargopacket.cpp src/cargopacket.h
diffstat 2 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -217,7 +217,6 @@
 	this->empty = this->packets.empty();
 	this->count = 0;
 	this->feeder_share = 0;
-	this->source = INVALID_STATION;
 	this->days_in_transit = 0;
 
 	if (this->empty) return;
@@ -229,5 +228,4 @@
 		this->feeder_share += (*it)->feeder_share;
 	}
 	this->days_in_transit = dit / count;
-	this->source = (*packets.begin())->source;
 }
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -166,7 +166,6 @@
 	bool empty;           ///< Cache for whether this list is empty or not
 	uint count;           ///< Cache for the number of cargo entities
 	Money feeder_share;   ///< Cache for the feeder share
-	StationID source;     ///< Cache for the source of the packet
 	uint days_in_transit; ///< Cache for the number of days in transit
 
 public:
@@ -225,7 +224,7 @@
 	 */
 	FORCEINLINE StationID Source() const
 	{
-		return this->source;
+		return this->Empty() ? INVALID_STATION : this->packets.front()->source;;
 	}
 
 	/**