1
0
Fork 0

Codechange: Use std::unique_ptr for link graph schedule handlers. (#12988)

This removes manual memory management.
pull/12998/head
Peter Nelson 2024-10-15 02:11:06 +01:00 committed by GitHub
parent 4a6ac52d8c
commit d5b57a56f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 10 deletions

View File

@ -143,12 +143,12 @@ void LinkGraphSchedule::ShiftDates(TimerGameEconomy::Date interval)
*/
LinkGraphSchedule::LinkGraphSchedule()
{
this->handlers[0] = new InitHandler;
this->handlers[1] = new DemandHandler;
this->handlers[2] = new MCFHandler<MCF1stPass>;
this->handlers[3] = new FlowMapper(false);
this->handlers[4] = new MCFHandler<MCF2ndPass>;
this->handlers[5] = new FlowMapper(true);
this->handlers[0] = std::make_unique<InitHandler>();
this->handlers[1] = std::make_unique<DemandHandler>();
this->handlers[2] = std::make_unique<MCFHandler<MCF1stPass>>();
this->handlers[3] = std::make_unique<FlowMapper>(false);
this->handlers[4] = std::make_unique<MCFHandler<MCF2ndPass>>();
this->handlers[5] = std::make_unique<FlowMapper>(true);
}
/**
@ -157,9 +157,6 @@ LinkGraphSchedule::LinkGraphSchedule()
LinkGraphSchedule::~LinkGraphSchedule()
{
this->Clear();
for (const auto &handler : this->handlers) {
delete handler;
}
}
/**

View File

@ -42,7 +42,7 @@ private:
friend SaveLoadTable GetLinkGraphScheduleDesc();
protected:
ComponentHandler *handlers[6]; ///< Handlers to be run for each job.
std::array<std::unique_ptr<ComponentHandler>, 6> handlers{}; ///< Handlers to be run for each job.
GraphList schedule; ///< Queue for new jobs.
JobList running; ///< Currently running jobs.