Codechange: use std::string as std::map key, instead of stredup string

This commit is contained in:
Rubidium
2023-05-05 11:01:01 +02:00
committed by rubidium42
parent 72082aa7d3
commit bc389a86c9
10 changed files with 54 additions and 111 deletions

View File

@@ -84,12 +84,8 @@ void ScriptScanner::RescanDir()
void ScriptScanner::Reset()
{
for (const auto &item : this->info_list) {
free(item.first);
delete item.second;
}
for (const auto &item : this->info_single_list) {
free(item.first);
}
this->info_list.clear();
this->info_single_list.clear();
@@ -128,15 +124,16 @@ void ScriptScanner::RegisterScript(ScriptInfo *info)
return;
}
this->info_list[stredup(script_name)] = info;
this->info_list[script_name] = info;
if (!info->IsDeveloperOnly() || _settings_client.gui.ai_developer_tools) {
/* Add the script to the 'unique' script list, where only the highest version
* of the script is registered. */
if (this->info_single_list.find(script_original_name) == this->info_single_list.end()) {
this->info_single_list[stredup(script_original_name)] = info;
} else if (this->info_single_list[script_original_name]->GetVersion() < info->GetVersion()) {
auto it = this->info_single_list.find(script_original_name);
if (it == this->info_single_list.end()) {
this->info_single_list[script_original_name] = info;
} else if (it->second->GetVersion() < info->GetVersion()) {
it->second = info;
}
}
}