1
0
Fork 0

Codechange: Use result of .find() instead of looking up multiple times. (#14154)

pull/14158/head
Peter Nelson 2025-04-29 23:52:46 +01:00 committed by GitHub
parent aa9e8b422c
commit 0abebfce1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -103,20 +103,20 @@ void ScriptScanner::RegisterScript(ScriptInfo *info)
return;
}
if (this->info_list.find(script_name) != this->info_list.end()) {
if (auto it = this->info_list.find(script_name); it != this->info_list.end()) {
/* This script was already registered */
#ifdef _WIN32
/* Windows doesn't care about the case */
if (StrEqualsIgnoreCase(this->info_list[script_name]->GetMainScript(), info->GetMainScript())) {
if (StrEqualsIgnoreCase(it->second->GetMainScript(), info->GetMainScript())) {
#else
if (this->info_list[script_name]->GetMainScript() == info->GetMainScript()) {
if (it->second->GetMainScript() == info->GetMainScript()) {
#endif
delete info;
return;
}
Debug(script, 1, "Registering two scripts with the same name and version");
Debug(script, 1, " 1: {}", this->info_list[script_name]->GetMainScript());
Debug(script, 1, " 1: {}", it->second->GetMainScript());
Debug(script, 1, " 2: {}", info->GetMainScript());
Debug(script, 1, "The first is taking precedence.");