perf(config): added cache

In order to prevent traversing the YAML tree I have added a hash map (O(1) lookup) to cache already accessed config variables. I have also added a vector to store keys requested but not found so we do not need to check for those every time
This commit is contained in:
2025-02-20 09:30:43 -05:00
parent f1035bd84f
commit 31184647b7
2 changed files with 148 additions and 59 deletions

View File

@@ -29,3 +29,14 @@ bool Config::loadConfig(const std::string& configFile) {
return true;
}
bool Config::isKeyInCache(const std::string &key) {
return configMap.find(key) != configMap.end();
}
void Config::addToCache(const std::string &key, const YAML::Node &node) {
configMap[key] = node;
}
void Config::registerUnknownKey(const std::string &key) {
unknownKeys.push_back(key);
}