From 746dddc0673d7261f19b1e056e90e6e3a49ef33a Mon Sep 17 00:00:00 2001 From: reduz Date: Fri, 13 May 2022 15:04:37 +0200 Subject: 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! --- core/extension/extension_api_dump.cpp | 2 +- core/extension/native_extension.h | 2 +- core/extension/native_extension_manager.cpp | 4 ++-- core/extension/native_extension_manager.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'core/extension') diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 4d5dc7958c..9e8addf8aa 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -334,7 +334,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { { // Global enums and constants. Array constants; - Map>> enum_list; + HashMap>> enum_list; for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) { int value = CoreConstants::get_global_constant_value(i); diff --git a/core/extension/native_extension.h b/core/extension/native_extension.h index af5a474e79..8f106f753d 100644 --- a/core/extension/native_extension.h +++ b/core/extension/native_extension.h @@ -45,7 +45,7 @@ class NativeExtension : public Resource { ObjectNativeExtension native_extension; }; - Map extension_classes; + HashMap extension_classes; static void _register_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs); static void _register_extension_class_method(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info); diff --git a/core/extension/native_extension_manager.cpp b/core/extension/native_extension_manager.cpp index 5436f7d51e..186fcc44f6 100644 --- a/core/extension/native_extension_manager.cpp +++ b/core/extension/native_extension_manager.cpp @@ -90,9 +90,9 @@ Vector NativeExtensionManager::get_loaded_extensions() const { return ret; } Ref NativeExtensionManager::get_extension(const String &p_path) { - Map>::Element *E = native_extension_map.find(p_path); + HashMap>::Iterator E = native_extension_map.find(p_path); ERR_FAIL_COND_V(!E, Ref()); - return E->get(); + return E->value; } void NativeExtensionManager::initialize_extensions(NativeExtension::InitializationLevel p_level) { diff --git a/core/extension/native_extension_manager.h b/core/extension/native_extension_manager.h index b8339e4817..5594f6c0de 100644 --- a/core/extension/native_extension_manager.h +++ b/core/extension/native_extension_manager.h @@ -37,7 +37,7 @@ class NativeExtensionManager : public Object { GDCLASS(NativeExtensionManager, Object); int32_t level = -1; - Map> native_extension_map; + HashMap> native_extension_map; static void _bind_methods(); -- cgit v1.2.3