mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use std::unique_ptr for link graph schedule handlers. (#12988)
This removes manual memory management.pull/12998/head
parent
4a6ac52d8c
commit
d5b57a56f4
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue