mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
1cab0dbc1d
commit
31acc42b21
|
@ -217,7 +217,6 @@ void CargoList::InvalidateCache()
|
||||||
this->empty = this->packets.empty();
|
this->empty = this->packets.empty();
|
||||||
this->count = 0;
|
this->count = 0;
|
||||||
this->feeder_share = 0;
|
this->feeder_share = 0;
|
||||||
this->source = INVALID_STATION;
|
|
||||||
this->days_in_transit = 0;
|
this->days_in_transit = 0;
|
||||||
|
|
||||||
if (this->empty) return;
|
if (this->empty) return;
|
||||||
|
@ -229,5 +228,4 @@ void CargoList::InvalidateCache()
|
||||||
this->feeder_share += (*it)->feeder_share;
|
this->feeder_share += (*it)->feeder_share;
|
||||||
}
|
}
|
||||||
this->days_in_transit = dit / count;
|
this->days_in_transit = dit / count;
|
||||||
this->source = (*packets.begin())->source;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,6 @@ private:
|
||||||
bool empty; ///< Cache for whether this list is empty or not
|
bool empty; ///< Cache for whether this list is empty or not
|
||||||
uint count; ///< Cache for the number of cargo entities
|
uint count; ///< Cache for the number of cargo entities
|
||||||
Money feeder_share; ///< Cache for the feeder share
|
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
|
uint days_in_transit; ///< Cache for the number of days in transit
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -225,7 +224,7 @@ public:
|
||||||
*/
|
*/
|
||||||
FORCEINLINE StationID Source() const
|
FORCEINLINE StationID Source() const
|
||||||
{
|
{
|
||||||
return this->source;
|
return this->Empty() ? INVALID_STATION : this->packets.front()->source;;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue