Codechange: use std::string as std::map key, instead of stredup string
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user