FlowStat: Replace btree_map with flat map which is inlined in small case
Inline storage for size <= 2 Size = 1 is ~90% Size = 2 is ~9% Size >=3 is ~1% and gets a separate allocation
This commit is contained in:
@@ -1515,9 +1515,8 @@ struct StationViewWindow : public Window {
|
||||
for (FlowStatMap::const_iterator it = flows.begin(); it != flows.end(); ++it) {
|
||||
StationID from = it->GetOrigin();
|
||||
CargoDataEntry *source_entry = cargo_entry->InsertOrRetrieve(from);
|
||||
const FlowStat::SharesMap *shares = it->GetShares();
|
||||
uint32 prev_count = 0;
|
||||
for (FlowStat::SharesMap::const_iterator flow_it = shares->begin(); flow_it != shares->end(); ++flow_it) {
|
||||
for (FlowStat::const_iterator flow_it = it->begin(); flow_it != it->end(); ++flow_it) {
|
||||
StationID via = flow_it->second;
|
||||
CargoDataEntry *via_entry = source_entry->InsertOrRetrieve(via);
|
||||
if (via == this->window_number) {
|
||||
@@ -1546,9 +1545,8 @@ struct StationViewWindow : public Window {
|
||||
const FlowStatMap &flowmap = Station::Get(next)->goods[cargo].flows;
|
||||
FlowStatMap::const_iterator map_it = flowmap.find(source);
|
||||
if (map_it != flowmap.end()) {
|
||||
const FlowStat::SharesMap *shares = map_it->GetShares();
|
||||
uint32 prev_count = 0;
|
||||
for (FlowStat::SharesMap::const_iterator i = shares->begin(); i != shares->end(); ++i) {
|
||||
for (FlowStat::const_iterator i = map_it->begin(); i != map_it->end(); ++i) {
|
||||
tmp.InsertOrRetrieve(i->second)->Update(i->first - prev_count);
|
||||
prev_count = i->first;
|
||||
}
|
||||
@@ -1598,8 +1596,7 @@ struct StationViewWindow : public Window {
|
||||
for (FlowStatMap::const_iterator it = flows.begin(); it != flows.end(); ++it) {
|
||||
StationID from = it->GetOrigin();
|
||||
const CargoDataEntry *source_entry = source_dest->Retrieve(from);
|
||||
const FlowStat::SharesMap *shares = it->GetShares();
|
||||
for (FlowStat::SharesMap::const_iterator flow_it = shares->begin(); flow_it != shares->end(); ++flow_it) {
|
||||
for (FlowStat::const_iterator flow_it = it->begin(); flow_it != it->end(); ++flow_it) {
|
||||
const CargoDataEntry *via_entry = source_entry->Retrieve(flow_it->second);
|
||||
for (CargoDataSet::iterator dest_it = via_entry->Begin(); dest_it != via_entry->End(); ++dest_it) {
|
||||
CargoDataEntry *dest_entry = *dest_it;
|
||||
|
Reference in New Issue
Block a user