Codechange: Split GoodsEntry cargo and flows data to unique_ptr. (#13058)
This allows cargo packets and cargo flow data to be empty if not in use, which is the case for the majority of station goods entries, and data is allocated when needed. This reduces the initial size of a Station from 9192 bytes to 2024 bytes (on 64 bit platforms), although an allocation of 120 bytes is made for each active cargo type at a station. Based on similar changes in JGRPP.
This commit is contained in:
@@ -59,7 +59,10 @@ template<bool Tfrom, bool Tvia>
|
||||
return -1;
|
||||
}
|
||||
|
||||
const StationCargoList &cargo_list = ::Station::Get(station_id)->goods[cargo_id].cargo;
|
||||
const ::GoodsEntry &goods = ::Station::Get(station_id)->goods[cargo_id];
|
||||
if (!goods.HasData()) return 0;
|
||||
|
||||
const StationCargoList &cargo_list = goods.GetData().cargo;
|
||||
if (!Tfrom && !Tvia) return cargo_list.TotalCount();
|
||||
|
||||
uint16_t cargo_count = 0;
|
||||
@@ -107,7 +110,10 @@ template<bool Tfrom, bool Tvia>
|
||||
return -1;
|
||||
}
|
||||
|
||||
const FlowStatMap &flows = ::Station::Get(station_id)->goods[cargo_id].flows;
|
||||
const ::GoodsEntry &goods = ::Station::Get(station_id)->goods[cargo_id];
|
||||
if (!goods.HasData()) return 0;
|
||||
|
||||
const FlowStatMap &flows = goods.GetData().flows;
|
||||
if (Tfrom) {
|
||||
return Tvia ? flows.GetFlowFromVia(from_station_id, via_station_id) :
|
||||
flows.GetFlowFrom(from_station_id);
|
||||
|
||||
Reference in New Issue
Block a user