diff options
author | reduz <reduzio@gmail.com> | 2022-05-13 15:04:37 +0200 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2022-05-16 10:37:48 +0200 |
commit | 746dddc0673d7261f19b1e056e90e6e3a49ef33a (patch) | |
tree | 434b526eb286850ebccc6d2c998a7d90fdb8b5e2 /tests | |
parent | 396def9b66c476f7834604adb7136ca903ed01be (diff) |
Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
(order matters) but use is discouraged.
There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/object/test_class_db.h | 2 | ||||
-rw-r--r-- | tests/core/string/test_translation.h | 2 | ||||
-rw-r--r-- | tests/test_macros.cpp | 4 | ||||
-rw-r--r-- | tests/test_macros.h | 6 | ||||
-rw-r--r-- | tests/test_main.cpp | 6 |
5 files changed, 10 insertions, 10 deletions
diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h index 2e316a7d95..8aaca69d13 100644 --- a/tests/core/object/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -519,7 +519,7 @@ void add_exposed_classes(Context &r_context) { List<PropertyInfo> property_list; ClassDB::get_property_list(class_name, &property_list, true); - Map<StringName, StringName> accessor_methods; + HashMap<StringName, StringName> accessor_methods; for (const PropertyInfo &property : property_list) { if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY || (property.type == Variant::NIL && property.usage & PROPERTY_USAGE_ARRAY)) { diff --git a/tests/core/string/test_translation.h b/tests/core/string/test_translation.h index 85ac639bec..0a1903ccbf 100644 --- a/tests/core/string/test_translation.h +++ b/tests/core/string/test_translation.h @@ -154,7 +154,7 @@ TEST_CASE("[OptimizedTranslation] Generate from Translation and read messages") TEST_CASE("[Translation] CSV import") { Ref<ResourceImporterCSVTranslation> import_csv_translation = memnew(ResourceImporterCSVTranslation); - Map<StringName, Variant> options; + HashMap<StringName, Variant> options; options["compress"] = false; options["delimiter"] = 0; diff --git a/tests/test_macros.cpp b/tests/test_macros.cpp index aa07f8211a..8c510cb4a5 100644 --- a/tests/test_macros.cpp +++ b/tests/test_macros.cpp @@ -31,11 +31,11 @@ #define DOCTEST_CONFIG_IMPLEMENT #include "test_macros.h" -Map<String, TestFunc> *test_commands = nullptr; +HashMap<String, TestFunc> *test_commands = nullptr; int register_test_command(String p_command, TestFunc p_function) { if (!test_commands) { - test_commands = new Map<String, TestFunc>; + test_commands = new HashMap<String, TestFunc>; } test_commands->insert(p_command, p_function); return 0; diff --git a/tests/test_macros.h b/tests/test_macros.h index 9cb9624d52..189554bd1a 100644 --- a/tests/test_macros.h +++ b/tests/test_macros.h @@ -122,7 +122,7 @@ DOCTEST_STRINGIFY_VARIANT(PackedColorArray); // Example usage: `godot --test gdscript-parser`. typedef void (*TestFunc)(); -extern Map<String, TestFunc> *test_commands; +extern HashMap<String, TestFunc> *test_commands; int register_test_command(String p_command, TestFunc p_function); #define REGISTER_TEST_COMMAND(m_command, m_function) \ @@ -233,8 +233,8 @@ class SignalWatcher : public Object { private: inline static SignalWatcher *singleton; - /* Equal to: Map<String, Vector<Vector<Variant>>> */ - Map<String, Array> _signals; + /* Equal to: RBMap<String, Vector<Vector<Variant>>> */ + HashMap<String, Array> _signals; void _add_signal_entry(const Array &p_args, const String &p_name) { if (!_signals.has(p_name)) { _signals[p_name] = Array(); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 4cdc5ea1fa..a5f6fb9b88 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -105,9 +105,9 @@ int test_main(int argc, char *argv[]) { // Run custom test tools. if (test_commands) { - for (Map<String, TestFunc>::Element *E = test_commands->front(); E; E = E->next()) { - if (args.find(E->key())) { - const TestFunc &test_func = E->get(); + for (const KeyValue<String, TestFunc> &E : (*test_commands)) { + if (args.find(E.key)) { + const TestFunc &test_func = E.value; test_func(); run_tests = false; break; |