mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Emplace std::pair into vectors.
This creates the pair in the vector, instead of creating it then copying it in.
This commit is contained in:
parent
e31b3c67fc
commit
413c774e95
|
@ -293,7 +293,7 @@ private:
|
|||
for (uint i = 0; i != elements.size(); i++) {
|
||||
auto *lte = elements[i];
|
||||
if (i > 0 && elements[i - 1]->rating != lte->rating) rank = i;
|
||||
this->rows.emplace_back(std::make_pair(rank, lte));
|
||||
this->rows.emplace_back(rank, lte);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ void LinkGraphOverlay::RebuildCache()
|
|||
}
|
||||
}
|
||||
if (this->IsPointVisible(pta, &dpi)) {
|
||||
this->cached_stations.push_back(std::make_pair(from, supply));
|
||||
this->cached_stations.emplace_back(from, supply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
}
|
||||
|
||||
/* Insert new item. */
|
||||
this->data.push_front(std::make_pair(key, item));
|
||||
this->data.emplace_front(key, item);
|
||||
this->lookup.emplace(key, this->data.begin());
|
||||
}
|
||||
|
||||
|
|
|
@ -4225,9 +4225,9 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc
|
|||
}
|
||||
if (used_stations.empty()) {
|
||||
used_stations.reserve(2);
|
||||
used_stations.emplace_back(std::make_pair(first_station, 0));
|
||||
used_stations.emplace_back(first_station, 0);
|
||||
}
|
||||
used_stations.emplace_back(std::make_pair(st, 0));
|
||||
used_stations.emplace_back(st, 0);
|
||||
}
|
||||
|
||||
/* no stations around at all? */
|
||||
|
|
|
@ -2717,7 +2717,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
|||
|
||||
uint cur_prob = hs.probability;
|
||||
probability_max += cur_prob;
|
||||
probs.emplace_back(std::make_pair(hs.Index(), cur_prob));
|
||||
probs.emplace_back(hs.Index(), cur_prob);
|
||||
}
|
||||
|
||||
TileIndex baseTile = tile;
|
||||
|
|
|
@ -1545,7 +1545,7 @@ static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv)
|
|||
|
||||
/* Initialize sprite list and order. */
|
||||
for (auto p = psdv->rbegin(); p != psdv->rend(); p++) {
|
||||
sprite_list.push_front(std::make_pair((*p)->xmin + (*p)->ymin, *p));
|
||||
sprite_list.emplace_front((*p)->xmin + (*p)->ymin, *p);
|
||||
sprite_order.push(*p);
|
||||
(*p)->order = next_order++;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv)
|
|||
|
||||
/* Initialize sprite list and order. */
|
||||
for (auto p = psdv->rbegin(); p != psdv->rend(); p++) {
|
||||
sprite_list.push_front(std::make_pair((*p)->xmin + (*p)->ymin, *p));
|
||||
sprite_list.emplace_front((*p)->xmin + (*p)->ymin, *p);
|
||||
sprite_order.push(*p);
|
||||
(*p)->order = next_order++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue