Implements ConstString in several core places in the library, improving performance.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -2,30 +2,25 @@
|
||||
#include <algorithm>
|
||||
#include "../../Core/Exceptions/CreatureException.hpp"
|
||||
|
||||
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const std::string& growthRate,
|
||||
uint8_t CreatureLib::Library::GrowthRateLibrary::CalculateLevel(const Arbutils::CaseInsensitiveConstString& growthRate,
|
||||
uint32_t experience) const {
|
||||
auto g = growthRate;
|
||||
std::transform(g.begin(), g.end(), g.begin(), ::tolower);
|
||||
auto find = _growthRates.find(g);
|
||||
auto find = _growthRates.find(growthRate);
|
||||
if (find == _growthRates.end()) {
|
||||
throw CreatureException("Invalid growth rate was requested.");
|
||||
}
|
||||
return find->second->CalculateLevel(experience);
|
||||
}
|
||||
|
||||
uint32_t CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const std::string& growthRate,
|
||||
uint8_t level) const {
|
||||
auto g = growthRate;
|
||||
std::transform(g.begin(), g.end(), g.begin(), ::tolower);
|
||||
auto find = _growthRates.find(g);
|
||||
uint32_t
|
||||
CreatureLib::Library::GrowthRateLibrary::CalculateExperience(const Arbutils::CaseInsensitiveConstString& growthRate,
|
||||
uint8_t level) const {
|
||||
auto find = _growthRates.find(growthRate);
|
||||
if (find == _growthRates.end()) {
|
||||
throw CreatureException("Invalid growth rate was requested.");
|
||||
}
|
||||
return find->second->CalculateExperience(level);
|
||||
}
|
||||
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const std::string& name,
|
||||
void CreatureLib::Library::GrowthRateLibrary::AddGrowthRate(const Arbutils::CaseInsensitiveConstString& name,
|
||||
CreatureLib::Library::GrowthRate* rate) {
|
||||
auto g = name;
|
||||
std::transform(g.begin(), g.end(), g.begin(), ::tolower);
|
||||
_growthRates.insert({g, rate});
|
||||
_growthRates.insert({name, rate});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user