Allow most libraries to reserve capacity for their database.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-12-31 10:48:52 +01:00
parent db2eb0c3fa
commit 4d3dc28606
5 changed files with 13 additions and 5 deletions

View File

@@ -12,8 +12,11 @@ namespace CreatureLib::Library {
std::unordered_map<std::string, GrowthRate*> _growthRates;
public:
~GrowthRateLibrary(){
for (auto gr: _growthRates){
GrowthRateLibrary(size_t initialCapacity = 10)
: _growthRates(std::unordered_map<std::string, GrowthRate*>(initialCapacity)) {}
~GrowthRateLibrary() {
for (auto gr : _growthRates) {
delete gr.second;
}
}