mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use .fill() to clear an array instead of assigning a new array. (#13880)
Avoids allocating a temporary on the stack.pull/13848/head
parent
ca801d55d5
commit
fc7b6c6cbb
|
@ -787,7 +787,7 @@ static IntervalTimer<TimerGameEconomy> _economy_companies_yearly({TimerGameEcono
|
|||
for (Company *c : Company::Iterate()) {
|
||||
/* Move expenses to previous years. */
|
||||
std::rotate(std::rbegin(c->yearly_expenses), std::rbegin(c->yearly_expenses) + 1, std::rend(c->yearly_expenses));
|
||||
c->yearly_expenses[0] = {};
|
||||
c->yearly_expenses[0].fill(0);
|
||||
InvalidateWindowData(WC_FINANCES, c->index);
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
|
|||
Owner owner = c->index;
|
||||
int score = 0;
|
||||
|
||||
_score_part[owner] = {};
|
||||
_score_part[owner].fill(0);
|
||||
|
||||
/* Count vehicles */
|
||||
{
|
||||
|
|
|
@ -3072,7 +3072,7 @@ static IntervalTimer<TimerGameEconomy> _economy_industries_monthly({TimerGameEco
|
|||
|
||||
void InitializeIndustries()
|
||||
{
|
||||
Industry::industries = {};
|
||||
Industry::industries.fill({});
|
||||
_industry_sound_tile = TileIndex{};
|
||||
|
||||
_industry_builder.Reset();
|
||||
|
|
|
@ -675,8 +675,8 @@ static void UpdateVehicleViewportHash(Vehicle *v, int x, int y, int old_x, int o
|
|||
void ResetVehicleHash()
|
||||
{
|
||||
for (Vehicle *v : Vehicle::Iterate()) { v->hash_tile_current = nullptr; }
|
||||
_vehicle_viewport_hash = {};
|
||||
_vehicle_tile_hash = {};
|
||||
_vehicle_viewport_hash.fill(nullptr);
|
||||
_vehicle_tile_hash.fill(nullptr);
|
||||
}
|
||||
|
||||
void ResetVehicleColourMap()
|
||||
|
|
Loading…
Reference in New Issue