diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-04-15 15:18:34 +0200 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-05-04 16:08:55 +0200 |
commit | 955d5affa857ec1f358c56da8fb1ff4ab6590704 (patch) | |
tree | b667ac9f6f62bff17ce032683c0eb09727660555 /platform/ios | |
parent | 7ebc866418b075df58cbe4e31fcf8b0c3acd70a1 (diff) | |
download | redot-engine-955d5affa857ec1f358c56da8fb1ff4ab6590704.tar.gz |
Reduce and prevent unnecessary random-access to `List`
Random-access access to `List` when iterating is `O(n^2)` (`O(n)` when
accessing a single element)
* Removed subscript operator, in favor of a more explicit `get`
* Added conversion from `Iterator` to `ConstIterator`
* Remade existing operations into other solutions when applicable
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/export/godot_plugin_config.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/platform/ios/export/godot_plugin_config.cpp b/platform/ios/export/godot_plugin_config.cpp index 86d5c7ef5b..90e40b7c42 100644 --- a/platform/ios/export/godot_plugin_config.cpp +++ b/platform/ios/export/godot_plugin_config.cpp @@ -212,8 +212,8 @@ PluginConfigIOS PluginConfigIOS::load_plugin_config(Ref<ConfigFile> config_file, List<String> keys; config_file->get_section_keys(PluginConfigIOS::PLIST_SECTION, &keys); - for (int i = 0; i < keys.size(); i++) { - Vector<String> key_components = keys[i].split(":"); + for (const String &key : keys) { + Vector<String> key_components = key.split(":"); String key_value = ""; PluginConfigIOS::PlistItemType key_type = PluginConfigIOS::PlistItemType::UNKNOWN; @@ -245,29 +245,29 @@ PluginConfigIOS PluginConfigIOS::load_plugin_config(Ref<ConfigFile> config_file, switch (key_type) { case PluginConfigIOS::PlistItemType::STRING: { - String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], String()); + String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, key, String()); value = "<string>" + raw_value + "</string>"; } break; case PluginConfigIOS::PlistItemType::INTEGER: { - int raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], 0); + int raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, key, 0); Dictionary value_dictionary; String value_format = "<integer>$value</integer>"; value_dictionary["value"] = raw_value; value = value_format.format(value_dictionary, "$_"); } break; case PluginConfigIOS::PlistItemType::BOOLEAN: - if (config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], false)) { + if (config_file->get_value(PluginConfigIOS::PLIST_SECTION, key, false)) { value = "<true/>"; } else { value = "<false/>"; } break; case PluginConfigIOS::PlistItemType::RAW: { - String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], String()); + String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, key, String()); value = raw_value; } break; case PluginConfigIOS::PlistItemType::STRING_INPUT: { - String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, keys[i], String()); + String raw_value = config_file->get_value(PluginConfigIOS::PLIST_SECTION, key, String()); value = raw_value; } break; default: |