mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-21 05:29:11 +00:00
Codechange: Use .fill() to clear an array instead of assigning a new array. (#13880)
Avoids allocating a temporary on the stack.
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user