You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This introduces a performance enhancement by implementing a cache within the ConfigManager. This change reduces the overhead associated with accessing standard configuration variables, leading to more efficient retrieval and improved overall performance.
if (configs.contains(key) && std::holds_alternative<std::string>(configs.at(key))) {
442
-
returnstd::get<std::string>(configs.at(key));
444
+
auto itCache = m_configString.find(key);
445
+
if (itCache != m_configString.end()) {
446
+
returnitCache->second;
443
447
}
448
+
449
+
auto it = configs.find(key);
450
+
if (it != configs.end()) {
451
+
if (constauto* value = std::get_if<std::string>(&it->second)) {
452
+
m_configString[key] = *value;
453
+
return *value;
454
+
}
455
+
}
456
+
457
+
staticconst std::string staticEmptyString;
444
458
g_logger().warn("[{}] accessing invalid or wrong type index: {}[{}]. Called line: {}:{}, in {}", __FUNCTION__, magic_enum::enum_name(key), fmt::underlying(key), location.line(), location.column(), location.function_name());
if (configs.contains(key) && std::holds_alternative<int32_t>(configs.at(key))) {
450
-
return std::get<int32_t>(configs.at(key));
463
+
auto itCache = m_configInteger.find(key);
464
+
if (itCache != m_configInteger.end()) {
465
+
return itCache->second;
451
466
}
467
+
468
+
auto it = configs.find(key);
469
+
if (it != configs.end()) {
470
+
if (std::holds_alternative<int32_t>(it->second)) {
471
+
constauto value = std::get<int32_t>(it->second);
472
+
m_configInteger[key] = value;
473
+
return value;
474
+
}
475
+
}
476
+
452
477
g_logger().warn("[{}] accessing invalid or wrong type index: {}[{}]. Called line: {}:{}, in {}", __FUNCTION__, magic_enum::enum_name(key), fmt::underlying(key), location.line(), location.column(), location.function_name());
if (configs.contains(key) && std::holds_alternative<bool>(configs.at(key))) {
458
-
return std::get<bool>(configs.at(key));
482
+
auto itCache = m_configBoolean.find(key);
483
+
if (itCache != m_configBoolean.end()) {
484
+
return itCache->second;
459
485
}
486
+
487
+
auto it = configs.find(key);
488
+
if (it != configs.end()) {
489
+
if (std::holds_alternative<bool>(it->second)) {
490
+
constauto value = std::get<bool>(it->second);
491
+
m_configBoolean[key] = value;
492
+
return value;
493
+
}
494
+
}
495
+
460
496
g_logger().warn("[{}] accessing invalid or wrong type index: {}[{}]. Called line: {}:{}, in {}", __FUNCTION__, magic_enum::enum_name(key), fmt::underlying(key), location.line(), location.column(), location.function_name());
if (configs.contains(key) && std::holds_alternative<float>(configs.at(key))) {
466
-
return std::get<float>(configs.at(key));
501
+
auto itCache = m_configFloat.find(key);
502
+
if (itCache != m_configFloat.end()) {
503
+
return itCache->second;
467
504
}
505
+
506
+
auto it = configs.find(key);
507
+
if (it != configs.end()) {
508
+
if (std::holds_alternative<float>(it->second)) {
509
+
constauto value = std::get<float>(it->second);
510
+
m_configFloat[key] = value;
511
+
return value;
512
+
}
513
+
}
514
+
468
515
g_logger().warn("[{}] accessing invalid or wrong type index: {}[{}]. Called line: {}:{}, in {}", __FUNCTION__, magic_enum::enum_name(key), fmt::underlying(key), location.line(), location.column(), location.function_name());
0 commit comments