diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-07 09:04:44 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-07 09:04:44 +0200 |
commit | e63252b4219680d109bfa41c24f483e97b37f40e (patch) | |
tree | 8b8af6d7efcab9b2692d45dec65449fd83d2c8b9 /tests/core | |
parent | 570220ba9b127325f1a5aa7bb17d5c6f76ccf62c (diff) | |
parent | 955d5affa857ec1f358c56da8fb1ff4ab6590704 (diff) | |
download | redot-engine-e63252b4219680d109bfa41c24f483e97b37f40e.tar.gz |
Merge pull request #90705 from AThousandShips/foreach_list
Reduce and prevent unnecessary random-access to `List`
Diffstat (limited to 'tests/core')
-rw-r--r-- | tests/core/object/test_class_db.h | 14 | ||||
-rw-r--r-- | tests/core/object/test_object.h | 2 | ||||
-rw-r--r-- | tests/core/os/test_os.h | 4 | ||||
-rw-r--r-- | tests/core/variant/test_dictionary.h | 2 |
4 files changed, 10 insertions, 12 deletions
diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h index 5623c1d495..fb62d0f056 100644 --- a/tests/core/object/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -550,8 +550,6 @@ void add_exposed_classes(Context &r_context) { for (const MethodInfo &E : method_list) { const MethodInfo &method_info = E; - int argc = method_info.arguments.size(); - if (method_info.name.is_empty()) { continue; } @@ -613,8 +611,9 @@ void add_exposed_classes(Context &r_context) { method.return_type.name = Variant::get_type_name(return_info.type); } - for (int i = 0; i < argc; i++) { - PropertyInfo arg_info = method_info.arguments[i]; + int i = 0; + for (List<PropertyInfo>::ConstIterator itr = method_info.arguments.begin(); itr != method_info.arguments.end(); ++itr, ++i) { + const PropertyInfo &arg_info = *itr; String orig_arg_name = arg_info.name; @@ -686,10 +685,9 @@ void add_exposed_classes(Context &r_context) { TEST_FAIL_COND(!String(signal.name).is_valid_identifier(), "Signal name is not a valid identifier: '", exposed_class.name, ".", signal.name, "'."); - int argc = method_info.arguments.size(); - - for (int i = 0; i < argc; i++) { - PropertyInfo arg_info = method_info.arguments[i]; + int i = 0; + for (List<PropertyInfo>::ConstIterator itr = method_info.arguments.begin(); itr != method_info.arguments.end(); ++itr, ++i) { + const PropertyInfo &arg_info = *itr; String orig_arg_name = arg_info.name; diff --git a/tests/core/object/test_object.h b/tests/core/object/test_object.h index 3a3013a102..d714d71416 100644 --- a/tests/core/object/test_object.h +++ b/tests/core/object/test_object.h @@ -142,7 +142,7 @@ TEST_CASE("[Object] Core getters") { inheritance_list.size() == 1, "The inheritance list should consist of Object only"); CHECK_MESSAGE( - inheritance_list[0] == "Object", + inheritance_list.front()->get() == "Object", "The inheritance list should consist of Object only"); } diff --git a/tests/core/os/test_os.h b/tests/core/os/test_os.h index 63f8b18238..6ee0ff82e7 100644 --- a/tests/core/os/test_os.h +++ b/tests/core/os/test_os.h @@ -79,8 +79,8 @@ TEST_CASE("[OS] Non-UTF-8 environment variables") { TEST_CASE("[OS] Command line arguments") { List<String> arguments = OS::get_singleton()->get_cmdline_args(); bool found = false; - for (int i = 0; i < arguments.size(); i++) { - if (arguments[i] == "--test") { + for (const String &arg : arguments) { + if (arg == "--test") { found = true; break; } diff --git a/tests/core/variant/test_dictionary.h b/tests/core/variant/test_dictionary.h index 5bc56075da..aba20972d9 100644 --- a/tests/core/variant/test_dictionary.h +++ b/tests/core/variant/test_dictionary.h @@ -105,7 +105,7 @@ TEST_CASE("[Dictionary] get_key_lists()") { map[1] = 3; map.get_key_list(ptr); CHECK(keys.size() == 1); - CHECK(int(keys[0]) == 1); + CHECK(int(keys.front()->get()) == 1); map[2] = 4; map.get_key_list(ptr); CHECK(keys.size() == 3); |