1
0
Fork 0
pull/12295/merge
Máté Szabó 2024-12-25 20:24:01 +01:00 committed by GitHub
commit bc80190df7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 8 deletions

View File

@ -1059,7 +1059,7 @@ private:
};
uint num_children; ///< the number of subentries belonging to this entry.
uint count; ///< sum of counts of all children or amount of cargo for this entry.
CargoDataSet *children; ///< the children of this entry.
std::unique_ptr<CargoDataSet> children; ///< the children of this entry.
};
CargoDataEntry::CargoDataEntry() :
@ -1067,7 +1067,7 @@ CargoDataEntry::CargoDataEntry() :
station(INVALID_STATION),
num_children(0),
count(0),
children(new CargoDataSet(CargoSorter(CargoSortType::CargoID)))
children(std::make_unique<CargoDataSet>(CargoSorter(CargoSortType::CargoID)))
{}
CargoDataEntry::CargoDataEntry(CargoID cargo, uint count, CargoDataEntry *parent) :
@ -1075,7 +1075,7 @@ CargoDataEntry::CargoDataEntry(CargoID cargo, uint count, CargoDataEntry *parent
cargo(cargo),
num_children(0),
count(count),
children(new CargoDataSet)
children(std::make_unique<CargoDataSet>())
{}
CargoDataEntry::CargoDataEntry(StationID station, uint count, CargoDataEntry *parent) :
@ -1083,7 +1083,7 @@ CargoDataEntry::CargoDataEntry(StationID station, uint count, CargoDataEntry *pa
station(station),
num_children(0),
count(count),
children(new CargoDataSet)
children(std::make_unique<CargoDataSet>())
{}
CargoDataEntry::CargoDataEntry(StationID station) :
@ -1105,7 +1105,6 @@ CargoDataEntry::CargoDataEntry(CargoID cargo) :
CargoDataEntry::~CargoDataEntry()
{
this->Clear();
delete this->children;
}
/**
@ -1183,9 +1182,7 @@ void CargoDataEntry::IncrementSize()
void CargoDataEntry::Resort(CargoSortType type, SortOrder order)
{
CargoDataSet *new_subs = new CargoDataSet(this->children->begin(), this->children->end(), CargoSorter(type, order));
delete this->children;
this->children = new_subs;
this->children = std::make_unique<CargoDataSet>(this->children->begin(), this->children->end(), CargoSorter(type, order));
}
CargoDataEntry *CargoDataEntry::Retrieve(CargoDataSet::iterator i) const