From 746dddc0673d7261f19b1e056e90e6e3a49ef33a Mon Sep 17 00:00:00 2001 From: reduz Date: Fri, 13 May 2022 15:04:37 +0200 Subject: [PATCH] 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/config/engine.cpp | 4 +- core/config/engine.h | 2 +- core/config/project_settings.cpp | 51 ++--- core/config/project_settings.h | 18 +- core/core_bind.cpp | 2 +- core/core_bind.h | 4 +- core/debugger/engine_debugger.cpp | 6 +- core/debugger/engine_debugger.h | 8 +- core/debugger/local_debugger.cpp | 4 +- core/debugger/local_debugger.h | 2 +- core/debugger/script_debugger.cpp | 2 +- core/debugger/script_debugger.h | 8 +- core/doc_data.h | 4 +- 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 +- core/input/input.cpp | 40 ++-- core/input/input.h | 18 +- core/input/input_map.cpp | 4 +- core/io/file_access_memory.cpp | 12 +- core/io/file_access_network.h | 2 +- core/io/file_access_pack.cpp | 2 +- core/io/file_access_pack.h | 31 ++- core/io/file_access_zip.h | 4 +- core/io/ip.cpp | 4 +- core/io/ip.h | 2 +- core/io/json.cpp | 4 +- core/io/json.h | 2 +- core/io/logger.cpp | 4 +- core/io/packed_data_container.cpp | 4 +- core/io/packed_data_container.h | 2 +- core/io/resource.cpp | 8 +- core/io/resource.h | 6 +- core/io/resource_format_binary.cpp | 8 +- core/io/resource_format_binary.h | 20 +- core/io/resource_importer.cpp | 4 +- core/io/resource_importer.h | 6 +- core/io/resource_loader.cpp | 6 +- core/io/resource_loader.h | 6 +- core/math/a_star.cpp | 8 +- core/math/a_star.h | 2 +- core/math/color.cpp | 2 +- core/math/disjoint_set.h | 52 ++--- core/math/geometry_3d.cpp | 2 +- core/math/octree.h | 6 +- core/math/quick_hull.cpp | 36 ++-- core/math/quick_hull.h | 9 +- core/math/static_raycaster.h | 2 +- core/math/triangle_mesh.cpp | 6 +- core/multiplayer/multiplayer_api.cpp | 2 +- core/multiplayer/multiplayer_api.h | 4 +- core/object/class_db.cpp | 4 +- core/object/class_db.h | 10 +- core/object/message_queue.cpp | 6 +- core/object/object.cpp | 2 - core/object/object.h | 8 +- core/object/script_language.cpp | 28 +-- core/object/script_language.h | 14 +- core/object/script_language_extension.h | 6 +- core/string/optimized_translation.cpp | 6 +- core/string/translation.cpp | 34 +-- core/string/translation.h | 18 +- core/templates/hash_map.h | 56 ++--- core/templates/hashfuncs.h | 33 ++- core/templates/pair.h | 11 +- core/templates/{map.h => rb_map.h} | 36 ++-- core/templates/{set.h => rb_set.h} | 28 +-- core/templates/rid_owner.h | 2 +- core/variant/variant_call.cpp | 12 +- core/variant/variant_parser.h | 2 +- drivers/gles3/shader_gles3.cpp | 2 +- drivers/gles3/shader_gles3.h | 8 +- drivers/gles3/storage/config.h | 4 +- drivers/gles3/storage/material_storage.cpp | 78 +++---- drivers/gles3/storage/material_storage.h | 36 ++-- drivers/gles3/storage/mesh_storage.cpp | 6 +- drivers/gles3/storage/mesh_storage.h | 2 +- drivers/unix/ip_unix.cpp | 12 +- drivers/unix/ip_unix.h | 2 +- drivers/unix/net_socket_posix.cpp | 2 +- drivers/vulkan/rendering_device_vulkan.cpp | 60 +++--- drivers/vulkan/rendering_device_vulkan.h | 22 +- drivers/vulkan/vulkan_context.h | 4 +- editor/animation_bezier_editor.cpp | 18 +- editor/animation_bezier_editor.h | 10 +- editor/animation_track_editor.cpp | 44 ++-- editor/animation_track_editor.h | 2 +- editor/audio_stream_preview.h | 2 +- editor/connections_dialog.cpp | 18 +- editor/connections_dialog.h | 2 +- editor/create_dialog.cpp | 2 +- editor/create_dialog.h | 2 +- .../debug_adapter/debug_adapter_parser.cpp | 14 +- .../debug_adapter/debug_adapter_protocol.cpp | 8 +- .../debug_adapter/debug_adapter_protocol.h | 4 +- .../debug_adapter/debug_adapter_types.h | 7 +- editor/debugger/editor_debugger_inspector.cpp | 8 +- editor/debugger/editor_debugger_inspector.h | 6 +- editor/debugger/editor_debugger_node.cpp | 2 +- editor/debugger/editor_debugger_node.h | 12 +- editor/debugger/editor_debugger_server.cpp | 2 +- editor/debugger/editor_debugger_server.h | 2 +- editor/debugger/editor_debugger_tree.h | 2 +- editor/debugger/editor_network_profiler.h | 2 +- .../debugger/editor_performance_profiler.cpp | 2 +- editor/debugger/editor_performance_profiler.h | 4 +- editor/debugger/editor_profiler.cpp | 38 ++-- editor/debugger/editor_profiler.h | 6 +- editor/debugger/script_editor_debugger.cpp | 8 +- editor/debugger/script_editor_debugger.h | 8 +- editor/dependency_editor.cpp | 14 +- editor/dependency_editor.h | 4 +- editor/doc_tools.cpp | 4 +- editor/doc_tools.h | 4 +- editor/editor_asset_installer.cpp | 8 +- editor/editor_asset_installer.h | 2 +- editor/editor_autoload_settings.cpp | 2 +- editor/editor_command_palette.cpp | 2 +- editor/editor_data.cpp | 18 +- editor/editor_data.h | 12 +- editor/editor_dir_dialog.h | 2 +- editor/editor_export.cpp | 32 +-- editor/editor_export.h | 26 +-- editor/editor_feature_profile.cpp | 14 +- editor/editor_feature_profile.h | 8 +- editor/editor_file_system.cpp | 34 +-- editor/editor_file_system.h | 20 +- editor/editor_folding.cpp | 16 +- editor/editor_folding.h | 6 +- editor/editor_help.cpp | 22 +- editor/editor_help.h | 14 +- editor/editor_help_search.cpp | 18 +- editor/editor_help_search.h | 10 +- editor/editor_inspector.cpp | 42 ++-- editor/editor_inspector.h | 16 +- editor/editor_log.h | 2 +- editor/editor_node.cpp | 46 ++-- editor/editor_node.h | 22 +- editor/editor_property_name_processor.cpp | 8 +- editor/editor_property_name_processor.h | 4 +- editor/editor_resource_picker.cpp | 30 +-- editor/editor_resource_picker.h | 4 +- editor/editor_resource_preview.h | 2 +- editor/editor_run_native.h | 2 +- editor/editor_sectioned_inspector.h | 2 +- editor/editor_settings.cpp | 22 +- editor/editor_settings.h | 6 +- editor/editor_settings_dialog.cpp | 4 +- editor/editor_themes.cpp | 4 +- editor/editor_toaster.h | 2 +- editor/editor_translation_parser.cpp | 6 +- editor/export_template_manager.cpp | 6 +- editor/fileserver/editor_file_server.cpp | 2 +- editor/fileserver/editor_file_server.h | 4 +- editor/filesystem_dock.cpp | 26 +-- editor/filesystem_dock.h | 16 +- editor/find_in_files.cpp | 28 +-- editor/find_in_files.h | 10 +- editor/import/collada.cpp | 20 +- editor/import/collada.h | 72 +++---- .../import/dynamic_font_import_settings.cpp | 22 +- editor/import/dynamic_font_import_settings.h | 4 +- editor/import/editor_import_collada.cpp | 42 ++-- editor/import/editor_import_collada.h | 2 +- editor/import/editor_import_plugin.cpp | 16 +- editor/import/editor_import_plugin.h | 4 +- editor/import/resource_importer_bitmask.cpp | 4 +- editor/import/resource_importer_bitmask.h | 4 +- editor/import/resource_importer_bmfont.cpp | 4 +- editor/import/resource_importer_bmfont.h | 4 +- .../resource_importer_csv_translation.cpp | 4 +- .../resource_importer_csv_translation.h | 4 +- .../import/resource_importer_dynamic_font.cpp | 4 +- .../import/resource_importer_dynamic_font.h | 4 +- editor/import/resource_importer_image.cpp | 4 +- editor/import/resource_importer_image.h | 4 +- editor/import/resource_importer_imagefont.cpp | 4 +- editor/import/resource_importer_imagefont.h | 4 +- .../resource_importer_layered_texture.cpp | 4 +- .../resource_importer_layered_texture.h | 6 +- editor/import/resource_importer_obj.cpp | 12 +- editor/import/resource_importer_obj.h | 6 +- editor/import/resource_importer_scene.cpp | 36 ++-- editor/import/resource_importer_scene.h | 30 +-- .../import/resource_importer_shader_file.cpp | 4 +- editor/import/resource_importer_shader_file.h | 4 +- editor/import/resource_importer_texture.cpp | 4 +- editor/import/resource_importer_texture.h | 6 +- .../resource_importer_texture_atlas.cpp | 18 +- .../import/resource_importer_texture_atlas.h | 6 +- editor/import/resource_importer_wav.cpp | 4 +- editor/import/resource_importer_wav.h | 4 +- editor/import/scene_import_settings.cpp | 10 +- editor/import/scene_import_settings.h | 24 +-- editor/import_defaults_editor.cpp | 4 +- editor/import_dock.cpp | 8 +- editor/import_dock.h | 2 +- editor/inspector_dock.cpp | 4 +- .../animation_blend_tree_editor_plugin.cpp | 14 +- .../animation_blend_tree_editor_plugin.h | 2 +- .../animation_state_machine_editor.cpp | 2 +- .../plugins/animation_state_machine_editor.h | 4 +- editor/plugins/asset_library_editor_plugin.h | 2 +- editor/plugins/canvas_item_editor_plugin.cpp | 10 +- editor/plugins/canvas_item_editor_plugin.h | 2 +- editor/plugins/control_editor_plugin.cpp | 2 +- editor/plugins/editor_preview_plugins.cpp | 4 +- editor/plugins/gdextension_export_plugin.h | 4 +- .../gpu_particles_3d_editor_plugin.cpp | 6 +- .../mesh_instance_3d_editor_plugin.cpp | 2 +- editor/plugins/mesh_library_editor_plugin.cpp | 2 +- editor/plugins/multimesh_editor_plugin.cpp | 6 +- editor/plugins/node_3d_editor_gizmos.cpp | 8 +- editor/plugins/node_3d_editor_gizmos.h | 8 +- editor/plugins/node_3d_editor_plugin.cpp | 38 ++-- editor/plugins/node_3d_editor_plugin.h | 2 +- .../packed_scene_translation_parser_plugin.h | 4 +- editor/plugins/root_motion_editor_plugin.cpp | 6 +- editor/plugins/script_editor_plugin.cpp | 42 ++-- editor/plugins/script_editor_plugin.h | 4 +- editor/plugins/script_text_editor.cpp | 18 +- editor/plugins/script_text_editor.h | 4 +- editor/plugins/shader_editor_plugin.cpp | 2 +- editor/plugins/skeleton_3d_editor_plugin.cpp | 4 +- .../plugins/sprite_frames_editor_plugin.cpp | 4 +- editor/plugins/sprite_frames_editor_plugin.h | 4 +- editor/plugins/text_control_editor_plugin.cpp | 8 +- editor/plugins/text_control_editor_plugin.h | 2 +- editor/plugins/text_editor.cpp | 10 +- editor/plugins/text_editor.h | 2 +- editor/plugins/texture_region_editor_plugin.h | 2 +- editor/plugins/theme_editor_plugin.h | 2 +- editor/plugins/tiles/atlas_merging_dialog.cpp | 2 +- editor/plugins/tiles/atlas_merging_dialog.h | 2 +- editor/plugins/tiles/tile_atlas_view.cpp | 4 +- editor/plugins/tiles/tile_atlas_view.h | 2 +- editor/plugins/tiles/tile_data_editors.cpp | 28 +-- editor/plugins/tiles/tile_data_editors.h | 16 +- editor/plugins/tiles/tile_map_editor.cpp | 200 +++++++++--------- editor/plugins/tiles/tile_map_editor.h | 26 +-- .../tiles/tile_set_atlas_source_editor.cpp | 66 +++--- .../tiles/tile_set_atlas_source_editor.h | 14 +- .../plugins/visual_shader_editor_plugin.cpp | 26 +-- editor/plugins/visual_shader_editor_plugin.h | 12 +- editor/pot_generator.cpp | 6 +- editor/pot_generator.h | 4 +- editor/progress_dialog.h | 6 +- editor/project_export.cpp | 4 +- editor/project_manager.cpp | 26 +-- editor/project_manager.h | 2 +- editor/project_settings_editor.cpp | 4 +- editor/property_editor.cpp | 8 +- editor/property_selector.cpp | 16 +- editor/reparent_dialog.cpp | 2 +- editor/reparent_dialog.h | 2 +- editor/scene_tree_dock.cpp | 76 +++---- editor/scene_tree_dock.h | 20 +- editor/scene_tree_editor.cpp | 4 +- editor/scene_tree_editor.h | 4 +- editor/shader_create_dialog.cpp | 2 +- main/main.cpp | 6 +- modules/csg/csg.cpp | 6 +- modules/csg/csg.h | 10 +- modules/enet/enet_multiplayer_peer.h | 4 +- .../gdscript/editor/gdscript_highlighter.h | 2 +- .../gdscript_translation_parser_plugin.h | 8 +- modules/gdscript/gdscript.cpp | 110 +++++----- modules/gdscript/gdscript.h | 70 +++--- modules/gdscript/gdscript_analyzer.cpp | 8 +- modules/gdscript/gdscript_analyzer.h | 2 +- modules/gdscript/gdscript_byte_codegen.h | 42 ++-- modules/gdscript/gdscript_cache.cpp | 4 +- modules/gdscript/gdscript_cache.h | 4 +- modules/gdscript/gdscript_compiler.cpp | 18 +- modules/gdscript/gdscript_compiler.h | 14 +- modules/gdscript/gdscript_editor.cpp | 44 ++-- modules/gdscript/gdscript_function.cpp | 2 +- modules/gdscript/gdscript_function.h | 2 +- modules/gdscript/gdscript_parser.cpp | 4 +- modules/gdscript/gdscript_parser.h | 12 +- modules/gdscript/gdscript_tokenizer.h | 8 +- modules/gdscript/gdscript_vm.cpp | 4 +- .../gdscript_extend_parser.cpp | 4 +- .../gdscript_text_document.cpp | 8 +- .../language_server/gdscript_workspace.cpp | 56 ++--- .../language_server/gdscript_workspace.h | 6 +- modules/gdscript/language_server/lsp.hpp | 10 +- modules/gdscript/register_types.cpp | 2 +- .../gdscript/tests/gdscript_test_runner.cpp | 4 +- .../editor/editor_scene_importer_blend.cpp | 4 +- .../gltf/editor/editor_scene_importer_blend.h | 4 +- .../gltf/editor/editor_scene_importer_fbx.cpp | 6 +- .../gltf/editor/editor_scene_importer_fbx.h | 4 +- .../editor/editor_scene_importer_gltf.cpp | 2 +- .../gltf/editor/editor_scene_importer_gltf.h | 2 +- modules/gltf/gltf_animation.cpp | 2 +- modules/gltf/gltf_animation.h | 4 +- modules/gltf/gltf_document.cpp | 48 ++--- modules/gltf/gltf_document.h | 14 +- modules/gltf/gltf_skeleton.cpp | 2 +- modules/gltf/gltf_skeleton.h | 8 +- modules/gltf/gltf_skin.cpp | 12 +- modules/gltf/gltf_skin.h | 4 +- modules/gltf/gltf_state.cpp | 2 +- modules/gltf/gltf_state.h | 22 +- modules/gridmap/grid_map.cpp | 21 +- modules/gridmap/grid_map.h | 21 +- modules/jsonrpc/jsonrpc.h | 2 +- modules/minimp3/resource_importer_mp3.cpp | 4 +- modules/minimp3/resource_importer_mp3.h | 4 +- modules/mono/csharp_script.cpp | 38 ++-- modules/mono/csharp_script.h | 28 +-- modules/mono/editor/bindings_generator.cpp | 42 ++-- modules/mono/editor/bindings_generator.h | 10 +- modules/mono/glue/base_object_glue.cpp | 4 +- modules/mono/managed_callable.cpp | 2 +- modules/mono/managed_callable.h | 2 +- modules/mono/mono_gd/gd_mono_assembly.cpp | 4 +- modules/mono/mono_gd/gd_mono_assembly.h | 4 +- modules/mono/mono_gd/gd_mono_class.cpp | 20 +- modules/mono/mono_gd/gd_mono_class.h | 8 +- modules/mono/mono_gd/gd_mono_utils.cpp | 2 +- modules/navigation/nav_map.cpp | 4 +- modules/navigation/nav_map.h | 2 +- modules/navigation/nav_utils.h | 12 +- .../extensions/openxr_extension_wrapper.h | 6 +- modules/openxr/openxr_api.cpp | 22 +- modules/openxr/openxr_api.h | 6 +- modules/openxr/openxr_interface.cpp | 2 +- modules/raycast/lightmap_raycaster.cpp | 6 +- modules/raycast/lightmap_raycaster.h | 6 +- modules/raycast/raycast_occlusion_cull.cpp | 2 +- modules/raycast/raycast_occlusion_cull.h | 4 +- modules/raycast/static_raycaster.cpp | 6 +- modules/raycast/static_raycaster.h | 4 +- modules/regex/regex.cpp | 8 +- modules/regex/regex.h | 4 +- modules/text_server_adv/text_server_adv.cpp | 2 +- modules/text_server_adv/text_server_adv.h | 5 +- .../editor/visual_script_editor.cpp | 64 +++--- .../editor/visual_script_editor.h | 18 +- .../visual_script_property_selector.cpp | 18 +- .../editor/visual_script_property_selector.h | 10 +- modules/visual_script/visual_script.cpp | 74 +++---- modules/visual_script/visual_script.h | 32 +-- modules/visual_script/visual_script_nodes.cpp | 2 +- .../vorbis/resource_importer_ogg_vorbis.cpp | 4 +- modules/vorbis/resource_importer_ogg_vorbis.h | 4 +- modules/webrtc/webrtc_multiplayer_peer.cpp | 36 ++-- modules/webrtc/webrtc_multiplayer_peer.h | 2 +- .../websocket/websocket_multiplayer_peer.h | 2 +- modules/websocket/wsl_client.cpp | 2 +- modules/websocket/wsl_server.cpp | 2 +- platform/android/api/java_class_wrapper.h | 6 +- platform/android/api/jni_singleton.h | 4 +- platform/android/export/export_plugin.cpp | 2 +- platform/android/export/export_plugin.h | 2 +- platform/android/java_class_wrapper.cpp | 4 +- platform/android/tts_android.cpp | 6 +- platform/android/tts_android.h | 2 +- platform/iphone/export/export_plugin.cpp | 8 +- platform/iphone/export/export_plugin.h | 2 +- platform/iphone/tts_ios.h | 4 +- .../javascript/display_server_javascript.cpp | 4 +- .../javascript/display_server_javascript.h | 2 +- platform/javascript/export/export_plugin.cpp | 6 +- platform/javascript/export/export_plugin.h | 4 +- platform/javascript/export/export_server.h | 2 +- platform/linuxbsd/display_server_x11.cpp | 28 +-- platform/linuxbsd/display_server_x11.h | 16 +- platform/linuxbsd/export/export_plugin.h | 2 +- platform/linuxbsd/tts_linux.h | 4 +- platform/osx/display_server_osx.h | 8 +- platform/osx/display_server_osx.mm | 38 ++-- platform/osx/export/export_plugin.cpp | 2 +- platform/osx/export/export_plugin.h | 4 +- platform/osx/export/plist.cpp | 21 +- platform/osx/export/plist.h | 2 +- platform/osx/gl_manager_osx_legacy.h | 2 +- platform/osx/gl_manager_osx_legacy.mm | 4 +- platform/osx/tts_osx.h | 4 +- platform/uwp/export/app_packager.cpp | 2 +- platform/uwp/export/app_packager.h | 2 +- platform/uwp/export/export_plugin.cpp | 2 +- platform/uwp/export/export_plugin.h | 2 +- platform/windows/display_server_windows.cpp | 4 +- platform/windows/display_server_windows.h | 8 +- platform/windows/export/export_plugin.cpp | 2 +- platform/windows/export/export_plugin.h | 2 +- platform/windows/gl_manager_windows.h | 2 +- platform/windows/os_windows.cpp | 2 +- platform/windows/os_windows.h | 2 +- platform/windows/tts_windows.h | 4 +- scene/2d/area_2d.cpp | 104 ++++----- scene/2d/area_2d.h | 4 +- scene/2d/audio_stream_player_2d.cpp | 2 +- scene/2d/collision_object_2d.h | 2 +- scene/2d/navigation_region_2d.cpp | 6 +- scene/2d/physics_body_2d.cpp | 52 ++--- scene/2d/physics_body_2d.h | 2 +- scene/2d/ray_cast_2d.h | 2 +- scene/2d/shape_cast_2d.h | 2 +- scene/2d/tile_map.cpp | 190 +++++++++-------- scene/2d/tile_map.h | 38 ++-- scene/2d/visible_on_screen_notifier_2d.h | 2 +- scene/3d/area_3d.cpp | 104 ++++----- scene/3d/area_3d.h | 4 +- scene/3d/audio_stream_player_3d.cpp | 6 +- scene/3d/collision_object_3d.cpp | 2 +- scene/3d/collision_object_3d.h | 4 +- scene/3d/label_3d.cpp | 24 +-- scene/3d/label_3d.h | 2 +- scene/3d/lightmapper.h | 6 +- scene/3d/mesh_instance_3d.cpp | 8 +- scene/3d/mesh_instance_3d.h | 2 +- scene/3d/physics_body_3d.cpp | 52 ++--- scene/3d/physics_body_3d.h | 6 +- scene/3d/ray_cast_3d.h | 2 +- scene/3d/skeleton_3d.cpp | 6 +- scene/3d/skeleton_3d.h | 2 +- scene/3d/spring_arm_3d.h | 2 +- scene/3d/vehicle_body_3d.h | 2 +- scene/3d/voxelizer.h | 2 +- scene/animation/animation_blend_tree.h | 2 +- .../animation_node_state_machine.cpp | 2 +- .../animation/animation_node_state_machine.h | 2 +- scene/animation/animation_player.cpp | 18 +- scene/animation/animation_player.h | 36 +++- scene/animation/animation_tree.cpp | 2 +- scene/animation/animation_tree.h | 2 +- scene/debugger/scene_debugger.cpp | 98 ++++----- scene/debugger/scene_debugger.h | 8 +- scene/gui/base_button.cpp | 8 +- scene/gui/base_button.h | 2 +- scene/gui/box_container.cpp | 2 +- scene/gui/code_edit.cpp | 10 +- scene/gui/code_edit.h | 6 +- scene/gui/flow_container.cpp | 2 +- scene/gui/graph_edit.cpp | 46 ++-- scene/gui/graph_edit.h | 16 +- scene/gui/graph_node.cpp | 2 +- scene/gui/graph_node.h | 2 +- scene/gui/grid_container.cpp | 16 +- scene/gui/popup_menu.h | 2 +- scene/gui/range.cpp | 4 +- scene/gui/range.h | 2 +- scene/gui/rich_text_label.cpp | 58 ++--- scene/gui/text_edit.h | 3 +- scene/main/node.cpp | 24 +-- scene/main/node.h | 18 +- scene/main/resource_preloader.cpp | 9 +- scene/main/resource_preloader.h | 2 +- scene/main/scene_tree.cpp | 80 +++---- scene/main/scene_tree.h | 10 +- scene/main/viewport.cpp | 42 ++-- scene/main/viewport.h | 12 +- scene/main/window.cpp | 4 +- scene/main/window.h | 2 +- scene/multiplayer/multiplayer_spawner.h | 2 +- scene/multiplayer/scene_cache_interface.cpp | 24 +-- scene/multiplayer/scene_cache_interface.h | 6 +- .../scene_replication_interface.cpp | 2 +- scene/multiplayer/scene_replication_state.cpp | 4 +- scene/multiplayer/scene_replication_state.h | 16 +- scene/resources/animation_library.h | 2 +- scene/resources/bit_map.cpp | 4 +- scene/resources/canvas_item_material.cpp | 2 +- scene/resources/canvas_item_material.h | 9 +- scene/resources/concave_polygon_shape_3d.cpp | 4 +- scene/resources/curve.cpp | 8 +- scene/resources/curve.h | 4 +- scene/resources/font.h | 2 +- scene/resources/importer_mesh.cpp | 20 +- scene/resources/material.cpp | 6 +- scene/resources/material.h | 7 +- scene/resources/mesh.cpp | 12 +- scene/resources/mesh_data_tool.cpp | 2 +- scene/resources/mesh_library.h | 4 +- scene/resources/navigation_mesh.cpp | 6 +- scene/resources/navigation_mesh.h | 8 +- scene/resources/packed_scene.cpp | 20 +- scene/resources/packed_scene.h | 10 +- scene/resources/particles_material.cpp | 2 +- scene/resources/particles_material.h | 10 +- scene/resources/polygon_path_finder.cpp | 28 +-- scene/resources/polygon_path_finder.h | 4 +- scene/resources/resource_format_text.cpp | 12 +- scene/resources/resource_format_text.h | 26 +-- scene/resources/shader.cpp | 4 +- scene/resources/shader.h | 8 +- scene/resources/sprite_frames.cpp | 44 ++-- scene/resources/sprite_frames.h | 14 +- scene/resources/syntax_highlighter.h | 4 +- scene/resources/tile_set.cpp | 28 +-- scene/resources/tile_set.h | 52 +++-- scene/resources/visual_shader.cpp | 58 ++--- scene/resources/visual_shader.h | 24 +-- scene/resources/visual_shader_nodes.cpp | 4 +- scene/resources/visual_shader_nodes.h | 2 +- .../visual_shader_particle_nodes.cpp | 8 +- .../resources/visual_shader_particle_nodes.h | 4 +- scene/resources/world_2d.h | 4 +- scene/resources/world_3d.h | 4 +- servers/audio/audio_stream.h | 4 +- servers/audio/effects/audio_effect_eq.cpp | 8 +- servers/audio/effects/audio_effect_eq.h | 2 +- servers/audio_server.cpp | 10 +- servers/audio_server.h | 6 +- servers/debugger/servers_debugger.cpp | 14 +- .../physics_server_3d_extension.cpp | 6 +- .../extensions/physics_server_3d_extension.h | 6 +- servers/physics_2d/godot_area_2d.cpp | 48 +++-- servers/physics_2d/godot_area_2d.h | 27 ++- .../physics_2d/godot_physics_server_2d.cpp | 8 +- servers/physics_2d/godot_physics_server_2d.h | 2 +- servers/physics_2d/godot_shape_2d.cpp | 18 +- servers/physics_2d/godot_shape_2d.h | 4 +- servers/physics_2d/godot_space_2d.cpp | 2 +- servers/physics_2d/godot_space_2d.h | 4 +- servers/physics_2d/godot_step_2d.cpp | 2 +- servers/physics_3d/godot_area_3d.cpp | 48 +++-- servers/physics_3d/godot_area_3d.h | 29 ++- servers/physics_3d/godot_body_3d.h | 4 +- .../physics_3d/godot_physics_server_3d.cpp | 8 +- servers/physics_3d/godot_physics_server_3d.h | 2 +- servers/physics_3d/godot_shape_3d.cpp | 14 +- servers/physics_3d/godot_shape_3d.h | 4 +- servers/physics_3d/godot_soft_body_3d.cpp | 8 +- servers/physics_3d/godot_soft_body_3d.h | 6 +- servers/physics_3d/godot_space_3d.cpp | 2 +- servers/physics_3d/godot_space_3d.h | 4 +- servers/physics_3d/godot_step_3d.cpp | 4 +- servers/physics_server_2d.cpp | 6 +- servers/physics_server_2d.h | 10 +- servers/physics_server_3d.cpp | 6 +- servers/physics_server_3d.h | 10 +- servers/rendering/renderer_canvas_cull.cpp | 10 +- servers/rendering/renderer_canvas_cull.h | 10 +- servers/rendering/renderer_rd/effects_rd.h | 16 +- .../render_forward_clustered.cpp | 10 +- .../render_forward_clustered.h | 4 +- .../scene_shader_forward_clustered.cpp | 8 +- .../scene_shader_forward_clustered.h | 8 +- .../scene_shader_forward_mobile.cpp | 8 +- .../scene_shader_forward_mobile.h | 6 +- .../renderer_rd/renderer_canvas_render_rd.cpp | 6 +- .../renderer_rd/renderer_canvas_render_rd.h | 6 +- .../renderer_rd/renderer_compositor_rd.h | 2 +- .../renderer_rd/renderer_scene_render_rd.cpp | 36 ++-- .../renderer_rd/renderer_scene_render_rd.h | 12 +- .../renderer_rd/renderer_scene_sky_rd.cpp | 6 +- .../renderer_rd/renderer_scene_sky_rd.h | 6 +- servers/rendering/renderer_rd/shader_rd.cpp | 4 +- servers/rendering/renderer_rd/shader_rd.h | 8 +- .../storage_rd/material_storage.cpp | 60 +++--- .../renderer_rd/storage_rd/material_storage.h | 18 +- .../renderer_rd/storage_rd/mesh_storage.cpp | 6 +- .../renderer_rd/storage_rd/mesh_storage.h | 2 +- .../storage_rd/particles_storage.cpp | 8 +- .../storage_rd/particles_storage.h | 8 +- .../renderer_rd/storage_rd/texture_storage.h | 2 +- servers/rendering/renderer_scene_cull.cpp | 48 ++--- servers/rendering/renderer_scene_cull.h | 36 ++-- servers/rendering/renderer_storage.h | 19 +- servers/rendering/renderer_viewport.cpp | 20 +- servers/rendering/renderer_viewport.h | 2 +- servers/rendering/rendering_device_binds.cpp | 2 +- servers/rendering/rendering_device_binds.h | 2 +- servers/rendering/shader_compiler.cpp | 8 +- servers/rendering/shader_compiler.h | 36 ++-- servers/rendering/shader_language.cpp | 58 ++--- servers/rendering/shader_language.h | 48 ++--- servers/rendering/shader_types.cpp | 4 +- servers/rendering/shader_types.h | 12 +- servers/rendering/shader_warnings.cpp | 6 +- servers/rendering/shader_warnings.h | 5 +- servers/text_server.h | 2 +- servers/xr/xr_positional_tracker.h | 4 +- tests/core/object/test_class_db.h | 2 +- tests/core/string/test_translation.h | 2 +- tests/test_macros.cpp | 4 +- tests/test_macros.h | 6 +- tests/test_main.cpp | 6 +- thirdparty/enet/godot.cpp | 17 +- thirdparty/misc/polypartition.cpp | 12 +- thirdparty/misc/polypartition.h | 6 +- 587 files changed, 3696 insertions(+), 3527 deletions(-) rename core/templates/{map.h => rb_map.h} (96%) rename core/templates/{set.h => rb_set.h} (97%) diff --git a/core/config/engine.cpp b/core/config/engine.cpp index ff8a8d283fa2..782d369ae6af 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -208,9 +208,9 @@ void Engine::add_singleton(const Singleton &p_singleton) { } Object *Engine::get_singleton_object(const StringName &p_name) const { - const Map::Element *E = singleton_ptrs.find(p_name); + HashMap::ConstIterator E = singleton_ptrs.find(p_name); ERR_FAIL_COND_V_MSG(!E, nullptr, "Failed to retrieve non-existent singleton '" + String(p_name) + "'."); - return E->get(); + return E->value; } bool Engine::is_singleton_user_created(const StringName &p_name) const { diff --git a/core/config/engine.h b/core/config/engine.h index eac96852b30a..82e3ee5487fd 100644 --- a/core/config/engine.h +++ b/core/config/engine.h @@ -69,7 +69,7 @@ class Engine { bool _in_physics = false; List singletons; - Map singleton_ptrs; + HashMap singleton_ptrs; bool editor_hint = false; bool project_manager_hint = false; diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index ba108d75daee..3ef9a69d069c 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -331,7 +331,7 @@ struct _VCSort { void ProjectSettings::_get_property_list(List *p_list) const { _THREAD_SAFE_METHOD_ - Set<_VCSort> vclist; + RBSet<_VCSort> vclist; for (const KeyValue &E : props) { const VariantContainer *v = &E.value; @@ -360,7 +360,7 @@ void ProjectSettings::_get_property_list(List *p_list) const { vclist.insert(vc); } - for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { + for (RBSet<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { String prop_info_name = E->get().name; int dot = prop_info_name.find("."); if (dot != -1 && !custom_prop_info.has(prop_info_name)) { @@ -764,7 +764,7 @@ Error ProjectSettings::save() { return error; } -Error ProjectSettings::_save_settings_binary(const String &p_file, const Map> &props, const CustomMap &p_custom, const String &p_custom_features) { +Error ProjectSettings::_save_settings_binary(const String &p_file, const HashMap> &props, const CustomMap &p_custom, const String &p_custom_features) { Error err; Ref file = FileAccess::open(p_file, FileAccess::WRITE, &err); ERR_FAIL_COND_V_MSG(err != OK, err, "Couldn't save project.binary at " + p_file + "."); @@ -800,19 +800,20 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Mapstore_32(count); //store how many properties are saved } - for (Map>::Element *E = props.front(); E; E = E->next()) { - for (String &key : E->get()) { - if (!E->key().is_empty()) { - key = E->key() + "/" + key; + for (const KeyValue> &E : props) { + for (const String &key : E.value) { + String k = key; + if (!E.key.is_empty()) { + k = E.key + "/" + k; } Variant value; - if (p_custom.has(key)) { - value = p_custom[key]; + if (p_custom.has(k)) { + value = p_custom[k]; } else { - value = get(key); + value = get(k); } - file->store_pascal_string(key); + file->store_pascal_string(k); int len; err = encode_variant(value, nullptr, len, true); @@ -831,7 +832,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map> &props, const CustomMap &p_custom, const String &p_custom_features) { +Error ProjectSettings::_save_settings_text(const String &p_file, const HashMap> &props, const CustomMap &p_custom, const String &p_custom_features) { Error err; Ref file = FileAccess::open(p_file, FileAccess::WRITE, &err); @@ -852,18 +853,18 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapstore_string("\n"); - for (const Map>::Element *E = props.front(); E; E = E->next()) { - if (E != props.front()) { + for (const KeyValue> &E : props) { + if (E.key != props.begin()->key) { file->store_string("\n"); } - if (!E->key().is_empty()) { - file->store_string("[" + E->key() + "]\n\n"); + if (!E.key.is_empty()) { + file->store_string("[" + E.key + "]\n\n"); } - for (const String &F : E->get()) { + for (const String &F : E.value) { String key = F; - if (!E->key().is_empty()) { - key = E->key() + "/" + key; + if (!E.key.is_empty()) { + key = E.key + "/" + key; } Variant value; if (p_custom.has(key)) { @@ -917,7 +918,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust project_features = _trim_to_supported_features(project_features); set_setting("application/config/features", project_features); - Set<_VCSort> vclist; + RBSet<_VCSort> vclist; if (p_merge_with_current) { for (const KeyValue &G : props) { @@ -946,19 +947,19 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust for (const KeyValue &E : p_custom) { // Lookup global prop to store in the same order - Map::Element *global_prop = props.find(E.key); + HashMap::Iterator global_prop = props.find(E.key); _VCSort vc; vc.name = E.key; - vc.order = global_prop ? global_prop->get().order : 0xFFFFFFF; + vc.order = global_prop ? global_prop->value.order : 0xFFFFFFF; vc.type = E.value.get_type(); vc.flags = PROPERTY_USAGE_STORAGE; vclist.insert(vc); } - Map> props; + HashMap> props; - for (Set<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { + for (RBSet<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { String category = E->get().name; String name = E->get().name; @@ -1051,7 +1052,7 @@ void ProjectSettings::set_custom_property_info(const String &p_prop, const Prope custom_prop_info[p_prop].name = p_prop; } -const Map &ProjectSettings::get_custom_property_info() const { +const HashMap &ProjectSettings::get_custom_property_info() const { return custom_prop_info; } diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 8655526edd7e..f8dc618cb801 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -34,14 +34,14 @@ #include "core/object/class_db.h" #include "core/os/thread_safe.h" #include "core/templates/hash_map.h" -#include "core/templates/set.h" +#include "core/templates/rb_set.h" class ProjectSettings : public Object { GDCLASS(ProjectSettings, Object); _THREAD_SAFE_CLASS_ public: - typedef Map CustomMap; + typedef HashMap CustomMap; static const String PROJECT_DATA_DIR_NAME_SUFFIX; enum { @@ -84,15 +84,15 @@ class ProjectSettings : public Object { int last_builtin_order = 0; uint64_t last_save_time = 0; - Map props; + HashMap props; String resource_path; - Map custom_prop_info; + HashMap custom_prop_info; bool disable_feature_overrides = false; bool using_datapack = false; List input_presets; - Set custom_features; - Map feature_overrides; + RBSet custom_features; + HashMap feature_overrides; HashMap autoloads; @@ -108,8 +108,8 @@ class ProjectSettings : public Object { Error _load_settings_binary(const String &p_path); Error _load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path); - Error _save_settings_text(const String &p_file, const Map> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); - Error _save_settings_binary(const String &p_file, const Map> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); + Error _save_settings_text(const String &p_file, const HashMap> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); + Error _save_settings_binary(const String &p_file, const HashMap> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); Error _save_custom_bnd(const String &p_file); @@ -168,7 +168,7 @@ class ProjectSettings : public Object { Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector &p_custom_features = Vector(), bool p_merge_with_current = true); Error save(); void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info); - const Map &get_custom_property_info() const; + const HashMap &get_custom_property_info() const; uint64_t get_last_saved_time() { return last_save_time; } Vector get_optimizer_presets() const; diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 7c3cbfe48db7..194c7fdefd7a 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -439,7 +439,7 @@ void OS::print_resources_by_type(const Vector &p_types) { print_line(vformat("Resources currently in use for the following types: %s", p_types)); - Map type_count; + RBMap type_count; List> resources; ResourceCache::get_cached_resources(&resources); diff --git a/core/core_bind.h b/core/core_bind.h index 76313dc1a88a..e4d15d5c9d15 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -680,8 +680,8 @@ class Engine : public Object { class EngineDebugger : public Object { GDCLASS(EngineDebugger, Object); - Map captures; - Map> profilers; + HashMap captures; + HashMap> profilers; protected: static void _bind_methods(); diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index 54760d8d65dd..263c75760b92 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -39,9 +39,9 @@ EngineDebugger *EngineDebugger::singleton = nullptr; ScriptDebugger *EngineDebugger::script_debugger = nullptr; -Map EngineDebugger::profilers; -Map EngineDebugger::captures; -Map EngineDebugger::protocols; +HashMap EngineDebugger::profilers; +HashMap EngineDebugger::captures; +HashMap EngineDebugger::protocols; void EngineDebugger::register_profiler(const StringName &p_name, const Profiler &p_func) { ERR_FAIL_COND_MSG(profilers.has(p_name), "Profiler already registered: " + p_name); diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h index fdfa41c9ccf6..a8a791f9b0e1 100644 --- a/core/debugger/engine_debugger.h +++ b/core/debugger/engine_debugger.h @@ -33,7 +33,7 @@ #include "core/string/string_name.h" #include "core/string/ustring.h" -#include "core/templates/map.h" +#include "core/templates/hash_map.h" #include "core/templates/vector.h" #include "core/variant/array.h" #include "core/variant/variant.h" @@ -96,9 +96,9 @@ class EngineDebugger { static EngineDebugger *singleton; static ScriptDebugger *script_debugger; - static Map profilers; - static Map captures; - static Map protocols; + static HashMap profilers; + static HashMap captures; + static HashMap protocols; public: _FORCE_INLINE_ static EngineDebugger *get_singleton() { return singleton; } diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index 4ed4c97c64a4..f378ba94c3f1 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -241,14 +241,14 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { } else if (line.begins_with("br") || line.begins_with("break")) { if (line.get_slice_count(" ") <= 1) { - const Map> &breakpoints = script_debugger->get_breakpoints(); + const HashMap> &breakpoints = script_debugger->get_breakpoints(); if (breakpoints.size() == 0) { print_line("No Breakpoints."); continue; } print_line("Breakpoint(s): " + itos(breakpoints.size())); - for (const KeyValue> &E : breakpoints) { + for (const KeyValue> &E : breakpoints) { print_line("\t" + String(E.value.front()->get()) + ":" + itos(E.key)); } diff --git a/core/debugger/local_debugger.h b/core/debugger/local_debugger.h index ecd805a6cb37..c687214c653c 100644 --- a/core/debugger/local_debugger.h +++ b/core/debugger/local_debugger.h @@ -42,7 +42,7 @@ class LocalDebugger : public EngineDebugger { ScriptsProfiler *scripts_profiler = nullptr; String target_function; - Map options; + HashMap options; Pair to_breakpoint(const String &p_line); void print_variables(const List &names, const List &values, const String &variable_prefix); diff --git a/core/debugger/script_debugger.cpp b/core/debugger/script_debugger.cpp index 4dd93249ef7d..1efa7f769048 100644 --- a/core/debugger/script_debugger.cpp +++ b/core/debugger/script_debugger.cpp @@ -50,7 +50,7 @@ int ScriptDebugger::get_depth() const { void ScriptDebugger::insert_breakpoint(int p_line, const StringName &p_source) { if (!breakpoints.has(p_line)) { - breakpoints[p_line] = Set(); + breakpoints[p_line] = RBSet(); } breakpoints[p_line].insert(p_source); } diff --git a/core/debugger/script_debugger.h b/core/debugger/script_debugger.h index feb6702b54f9..a5a72d7c5409 100644 --- a/core/debugger/script_debugger.h +++ b/core/debugger/script_debugger.h @@ -33,8 +33,8 @@ #include "core/object/script_language.h" #include "core/string/string_name.h" -#include "core/templates/map.h" -#include "core/templates/set.h" +#include "core/templates/rb_map.h" +#include "core/templates/rb_set.h" #include "core/templates/vector.h" class ScriptDebugger { @@ -44,7 +44,7 @@ class ScriptDebugger { int depth = -1; bool skip_breakpoints = false; - Map> breakpoints; + HashMap> breakpoints; ScriptLanguage *break_lang = nullptr; Vector error_stack_info; @@ -66,7 +66,7 @@ class ScriptDebugger { bool is_breakpoint(int p_line, const StringName &p_source) const; bool is_breakpoint_line(int p_line) const; void clear_breakpoints(); - const Map> &get_breakpoints() const { return breakpoints; } + const HashMap> &get_breakpoints() const { return breakpoints; } void debug(ScriptLanguage *p_lang, bool p_can_continue = true, bool p_is_error_breakpoint = false); ScriptLanguage *get_break_language() const; diff --git a/core/doc_data.h b/core/doc_data.h index 194a39a72953..af20b717d78f 100644 --- a/core/doc_data.h +++ b/core/doc_data.h @@ -32,7 +32,7 @@ #define DOC_DATA_H #include "core/io/xml_parser.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" #include "core/variant/variant.h" struct ScriptMemberInfo { @@ -161,7 +161,7 @@ class DocData { Vector operators; Vector signals; Vector constants; - Map enums; + HashMap enums; Vector properties; Vector theme_properties; bool is_script_doc = false; diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 4d5dc7958ca1..9e8addf8aae9 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 af5a474e792f..8f106f753dcb 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 5436f7d51e79..186fcc44f60b 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 b8339e481737..5594f6c0de33 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(); diff --git a/core/input/input.cpp b/core/input/input.cpp index 3a2e50a67402..4befdfac580c 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -227,8 +227,8 @@ Input::VelocityTrack::VelocityTrack() { bool Input::is_anything_pressed() const { _THREAD_SAFE_METHOD_ - for (Map::Element *E = action_state.front(); E; E = E->next()) { - if (E->get().pressed) { + for (const KeyValue &E : action_state) { + if (E.value.pressed) { return true; } } @@ -272,65 +272,65 @@ bool Input::is_action_pressed(const StringName &p_action, bool p_exact) const { bool Input::is_action_just_pressed(const StringName &p_action, bool p_exact) const { ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action)); - const Map::Element *E = action_state.find(p_action); + HashMap::ConstIterator E = action_state.find(p_action); if (!E) { return false; } - if (p_exact && E->get().exact == false) { + if (p_exact && E->value.exact == false) { return false; } if (Engine::get_singleton()->is_in_physics_frame()) { - return E->get().pressed && E->get().physics_frame == Engine::get_singleton()->get_physics_frames(); + return E->value.pressed && E->value.physics_frame == Engine::get_singleton()->get_physics_frames(); } else { - return E->get().pressed && E->get().process_frame == Engine::get_singleton()->get_process_frames(); + return E->value.pressed && E->value.process_frame == Engine::get_singleton()->get_process_frames(); } } bool Input::is_action_just_released(const StringName &p_action, bool p_exact) const { ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action)); - const Map::Element *E = action_state.find(p_action); + HashMap::ConstIterator E = action_state.find(p_action); if (!E) { return false; } - if (p_exact && E->get().exact == false) { + if (p_exact && E->value.exact == false) { return false; } if (Engine::get_singleton()->is_in_physics_frame()) { - return !E->get().pressed && E->get().physics_frame == Engine::get_singleton()->get_physics_frames(); + return !E->value.pressed && E->value.physics_frame == Engine::get_singleton()->get_physics_frames(); } else { - return !E->get().pressed && E->get().process_frame == Engine::get_singleton()->get_process_frames(); + return !E->value.pressed && E->value.process_frame == Engine::get_singleton()->get_process_frames(); } } float Input::get_action_strength(const StringName &p_action, bool p_exact) const { ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), 0.0, InputMap::get_singleton()->suggest_actions(p_action)); - const Map::Element *E = action_state.find(p_action); + HashMap::ConstIterator E = action_state.find(p_action); if (!E) { return 0.0f; } - if (p_exact && E->get().exact == false) { + if (p_exact && E->value.exact == false) { return 0.0f; } - return E->get().strength; + return E->value.strength; } float Input::get_action_raw_strength(const StringName &p_action, bool p_exact) const { - const Map::Element *E = action_state.find(p_action); + HashMap::ConstIterator E = action_state.find(p_action); if (!E) { return 0.0f; } - if (p_exact && E->get().exact == false) { + if (p_exact && E->value.exact == false) { return 0.0f; } - return E->get().raw_strength; + return E->value.raw_strength; } float Input::get_axis(const StringName &p_negative_action, const StringName &p_positive_action) const { @@ -1403,12 +1403,12 @@ String Input::get_joy_guid(int p_device) const { Array Input::get_connected_joypads() { Array ret; - Map::Element *elem = joy_names.front(); + HashMap::Iterator elem = joy_names.begin(); while (elem) { - if (elem->get().connected) { - ret.push_back(elem->key()); + if (elem->value.connected) { + ret.push_back(elem->key); } - elem = elem->next(); + ++elem; } return ret; } diff --git a/core/input/input.h b/core/input/input.h index 5a7cb84ece21..7bb7889a4386 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -82,11 +82,11 @@ class Input : public Object { private: MouseButton mouse_button_mask = MouseButton::NONE; - Set physical_keys_pressed; - Set keys_pressed; - Set joy_buttons_pressed; - Map _joy_axis; - //Map custom_action_press; + RBSet physical_keys_pressed; + RBSet keys_pressed; + RBSet joy_buttons_pressed; + RBMap _joy_axis; + //RBMap custom_action_press; Vector3 gravity; Vector3 accelerometer; Vector3 magnetometer; @@ -103,7 +103,7 @@ class Input : public Object { float raw_strength; }; - Map action_state; + HashMap action_state; bool emulate_touch_from_mouse = false; bool emulate_mouse_from_touch = false; @@ -137,8 +137,8 @@ class Input : public Object { }; VelocityTrack mouse_velocity_track; - Map touch_velocity_track; - Map joy_names; + HashMap touch_velocity_track; + HashMap joy_names; int fallback_mapping = -1; CursorShape default_shape = CURSOR_ARROW; @@ -231,7 +231,7 @@ class Input : public Object { uint64_t timestamp; }; - Map joy_vibration; + HashMap joy_vibration; static void _bind_methods(); diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 51c1cf9608b9..942c5248df0b 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -691,12 +691,12 @@ const HashMap>> &InputMap::get_builtins_with_featur return default_builtin_with_overrides_cache; } - HashMap>> builtins = get_builtins(); + const HashMap>> &builtins = get_builtins(); // Get a list of all built in inputs which are valid overrides for the OS // Key = builtin name (e.g. ui_accept) // Value = override/feature names (e.g. macos, if it was defined as "ui_accept.macos" and the platform supports that feature) - Map> builtins_with_overrides; + HashMap> builtins_with_overrides; for (const KeyValue>> &E : builtins) { String fullname = E.key; diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 943dc7230733..499d001234e9 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -32,13 +32,13 @@ #include "core/config/project_settings.h" #include "core/io/dir_access.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" -static Map> *files = nullptr; +static HashMap> *files = nullptr; void FileAccessMemory::register_file(String p_name, Vector p_data) { if (!files) { - files = memnew((Map>)); + files = memnew((HashMap>)); } String name; @@ -84,11 +84,11 @@ Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) { String name = fix_path(p_path); //name = DirAccess::normalize_path(name); - Map>::Element *E = files->find(name); + HashMap>::Iterator E = files->find(name); ERR_FAIL_COND_V_MSG(!E, ERR_FILE_NOT_FOUND, "Can't find file '" + p_path + "'."); - data = E->get().ptrw(); - length = E->get().size(); + data = E->value.ptrw(); + length = E->value.size(); pos = 0; return OK; diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 214d391c95fb..c7431752c051 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -52,7 +52,7 @@ class FileAccessNetworkClient { bool quit = false; Mutex mutex; Mutex blockrequest_mutex; - Map accesses; + HashMap accesses; Ref client; int32_t last_id = 0; int32_t lockcount = 0; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index ba120de68b78..89efdc493805 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -406,7 +406,7 @@ Error DirAccessPack::list_dir_begin() { list_dirs.push_back(E.key); } - for (Set::Element *E = current->files.front(); E; E = E->next()) { + for (RBSet::Element *E = current->files.front(); E; E = E->next()) { list_files.push_back(E->get()); } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 17e87c835a3d..404ad38c96b0 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -35,8 +35,8 @@ #include "core/io/file_access.h" #include "core/string/print_string.h" #include "core/templates/list.h" -#include "core/templates/map.h" -#include "core/templates/set.h" +#include "core/templates/rb_map.h" +#include "core/templates/rb_set.h" // Godot's packed file magic header ("GDPC" in ASCII). #define PACK_HEADER_MAGIC 0x43504447 @@ -72,23 +72,20 @@ class PackedData { struct PackedDir { PackedDir *parent = nullptr; String name; - Map subdirs; - Set files; + HashMap subdirs; + RBSet files; }; struct PathMD5 { uint64_t a = 0; uint64_t b = 0; - bool operator<(const PathMD5 &p_md5) const { - if (p_md5.a == a) { - return b < p_md5.b; - } else { - return a < p_md5.a; - } - } - bool operator==(const PathMD5 &p_md5) const { - return a == p_md5.a && b == p_md5.b; + bool operator==(const PathMD5 &p_val) const { + return (a == p_val.a) && (b == p_val.b); + } + static uint32_t hash(const PathMD5 &p_val) { + uint32_t h = hash_djb2_one_32(p_val.a); + return hash_djb2_one_32(p_val.b, h); } PathMD5() {} @@ -99,7 +96,7 @@ class PackedData { } }; - Map files; + HashMap files; Vector sources; @@ -186,15 +183,15 @@ class FileAccessPack : public FileAccess { Ref PackedData::try_open_path(const String &p_path) { PathMD5 pmd5(p_path.md5_buffer()); - Map::Element *E = files.find(pmd5); + HashMap::Iterator E = files.find(pmd5); if (!E) { return nullptr; //not found } - if (E->get().offset == 0) { + if (E->value.offset == 0) { return nullptr; //was erased } - return E->get().src->get_file(p_path, &E->get()); + return E->value.src->get_file(p_path, &E->value); } bool PackedData::has_path(const String &p_path) { diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index ae58d99a667c..6ea603546a2a 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -34,7 +34,7 @@ #ifdef MINIZIP_ENABLED #include "core/io/file_access_pack.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" #include "thirdparty/minizip/unzip.h" @@ -55,7 +55,7 @@ class ZipArchive : public PackSource { }; Vector packages; - Map files; + HashMap files; static ZipArchive *instance; diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 5156a5cb999b..25e3bef5fc7d 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -267,7 +267,7 @@ Array IP::_get_local_addresses() const { Array IP::_get_local_interfaces() const { Array results; - Map interfaces; + HashMap interfaces; get_local_interfaces(&interfaces); for (KeyValue &E : interfaces) { Interface_Info &c = E.value; @@ -289,7 +289,7 @@ Array IP::_get_local_interfaces() const { } void IP::get_local_addresses(List *r_addresses) const { - Map interfaces; + HashMap interfaces; get_local_interfaces(&interfaces); for (const KeyValue &E : interfaces) { for (const IPAddress &F : E.value.ip_addresses) { diff --git a/core/io/ip.h b/core/io/ip.h index 06ff8a4d70fa..4d83515e2b0a 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -92,7 +92,7 @@ class IP : public Object { virtual void _resolve_hostname(List &r_addresses, const String &p_hostname, Type p_type = TYPE_ANY) const = 0; Array get_resolve_item_addresses(ResolverID p_id) const; - virtual void get_local_interfaces(Map *r_interfaces) const = 0; + virtual void get_local_interfaces(HashMap *r_interfaces) const = 0; void erase_resolve_item(ResolverID p_id); void clear_cache(const String &p_hostname = ""); diff --git a/core/io/json.cpp b/core/io/json.cpp index 4b745dff449a..b3a9762e754e 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -55,7 +55,7 @@ String JSON::_make_indent(const String &p_indent, int p_size) { return indent_text; } -String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set &p_markers, bool p_full_precision) { +String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, RBSet &p_markers, bool p_full_precision) { String colon = ":"; String end_statement = ""; @@ -529,7 +529,7 @@ Error JSON::_parse_string(const String &p_json, Variant &r_ret, String &r_err_st } String JSON::stringify(const Variant &p_var, const String &p_indent, bool p_sort_keys, bool p_full_precision) { - Set markers; + RBSet markers; return _stringify(p_var, p_indent, 0, p_sort_keys, markers, p_full_precision); } diff --git a/core/io/json.h b/core/io/json.h index ed251938ecb6..f883d3963a29 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -70,7 +70,7 @@ class JSON : public RefCounted { static const char *tk_name[]; static String _make_indent(const String &p_indent, int p_size); - static String _stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set &p_markers, bool p_full_precision = false); + static String _stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, RBSet &p_markers, bool p_full_precision = false); static Error _get_token(const char32_t *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str); static Error _parse_value(Variant &value, Token &token, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str); static Error _parse_array(Array &array, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str); diff --git a/core/io/logger.cpp b/core/io/logger.cpp index c19fc2820bfe..925bfdbd02bd 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -128,7 +128,7 @@ void RotatedFileLogger::clear_old_backups() { da->list_dir_begin(); String f = da->get_next(); - Set backups; + RBSet backups; while (!f.is_empty()) { if (!da->current_is_dir() && f.begins_with(basename) && f.get_extension() == extension && f != base_path.get_file()) { backups.insert(f); @@ -141,7 +141,7 @@ void RotatedFileLogger::clear_old_backups() { // since backups are appended with timestamp and Set iterates them in sorted order, // first backups are the oldest int to_delete = backups.size() - max_backups; - for (Set::Element *E = backups.front(); E && to_delete > 0; E = E->next(), --to_delete) { + for (RBSet::Element *E = backups.front(); E && to_delete > 0; E = E->next(), --to_delete) { da->remove(E->get()); } } diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp index 027fdd51aad6..a45631814848 100644 --- a/core/io/packed_data_container.cpp +++ b/core/io/packed_data_container.cpp @@ -210,7 +210,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b } } -uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpdata, Map &string_cache) { +uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpdata, HashMap &string_cache) { switch (p_data.get_type()) { case Variant::STRING: { String s = p_data; @@ -321,7 +321,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpd Error PackedDataContainer::pack(const Variant &p_data) { Vector tmpdata; - Map string_cache; + HashMap string_cache; _pack(p_data, tmpdata, string_cache); datalen = tmpdata.size(); data.resize(tmpdata.size()); diff --git a/core/io/packed_data_container.h b/core/io/packed_data_container.h index f042b364ee6b..73c215aed84d 100644 --- a/core/io/packed_data_container.h +++ b/core/io/packed_data_container.h @@ -50,7 +50,7 @@ class PackedDataContainer : public Resource { Vector data; int datalen = 0; - uint32_t _pack(const Variant &p_data, Vector &tmpdata, Map &string_cache); + uint32_t _pack(const Variant &p_data, Vector &tmpdata, HashMap &string_cache); Variant _iter_init_ofs(const Array &p_iter, uint32_t p_offset); Variant _iter_next_ofs(const Array &p_iter, uint32_t p_offset); diff --git a/core/io/resource.cpp b/core/io/resource.cpp index e81382b72ed0..4a94c171327b 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -193,7 +193,7 @@ void Resource::reload_from_file() { copy_from(s); } -Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache) { +Ref Resource::duplicate_for_local_scene(Node *p_for_scene, HashMap, Ref> &remap_cache) { List plist; get_property_list(&plist); @@ -228,7 +228,7 @@ Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache) { +void Resource::configure_for_local_scene(Node *p_for_scene, HashMap, Ref> &remap_cache) { List plist; get_property_list(&plist); @@ -317,7 +317,7 @@ void Resource::unregister_owner(Object *p_owner) { } void Resource::notify_change_to_owners() { - for (Set::Element *E = owners.front(); E; E = E->next()) { + for (RBSet::Element *E = owners.front(); E; E = E->next()) { Object *obj = ObjectDB::get_instance(E->get()); ERR_CONTINUE_MSG(!obj, "Object was deleted, while still owning a resource."); //wtf //TODO store string @@ -532,7 +532,7 @@ void ResourceCache::dump(const char *p_file, bool p_short) { #ifdef DEBUG_ENABLED lock.read_lock(); - Map type_count; + HashMap type_count; Ref f; if (p_file) { diff --git a/core/io/resource.h b/core/io/resource.h index 43ae104da5d6..53c828f9cdf9 100644 --- a/core/io/resource.h +++ b/core/io/resource.h @@ -54,7 +54,7 @@ class Resource : public RefCounted { virtual String get_base_extension() const { return "res"; } private: - Set owners; + RBSet owners; friend class ResBase; friend class ResourceCache; @@ -111,8 +111,8 @@ class Resource : public RefCounted { String get_scene_unique_id() const; virtual Ref duplicate(bool p_subresources = false) const; - Ref duplicate_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache); - void configure_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache); + Ref duplicate_for_local_scene(Node *p_for_scene, HashMap, Ref> &remap_cache); + void configure_for_local_scene(Node *p_for_scene, HashMap, Ref> &remap_cache); void set_local_to_scene(bool p_enable); bool is_local_to_scene() const; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 3c854bbbe59e..cf87869a32a3 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1130,7 +1130,7 @@ void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List &p_map) { +Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, const HashMap &p_map) { Ref f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, "Cannot open file '" + p_path + "'."); @@ -1384,7 +1384,7 @@ void ResourceFormatSaverBinaryInstance::_pad_buffer(Ref f, int p_byt } } -void ResourceFormatSaverBinaryInstance::write_variant(Ref f, const Variant &p_property, Map, int> &resource_map, Map, int> &external_resources, Map &string_map, const PropertyInfo &p_hint) { +void ResourceFormatSaverBinaryInstance::write_variant(Ref f, const Variant &p_property, HashMap, int> &resource_map, HashMap, int> &external_resources, HashMap &string_map, const PropertyInfo &p_hint) { switch (p_property.get_type()) { case Variant::NIL: { f->store_32(VARIANT_NIL); @@ -2022,7 +2022,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Refstore_32(saved_resources.size()); //amount of internal resources Vector ofs_pos; - Set used_unique_ids; + RBSet used_unique_ids; for (Ref &r : saved_resources) { if (r->is_built_in()) { @@ -2036,7 +2036,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Ref, int> resource_map; + HashMap, int> resource_map; int res_index = 0; for (Ref &r : saved_resources) { if (r->is_built_in()) { diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 92d4e4eeaa57..db29909dd5c3 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -75,12 +75,12 @@ class ResourceLoaderBinary { }; Vector internal_resources; - Map> internal_index_cache; + HashMap> internal_index_cache; String get_unicode_string(); void _advance_padding(uint32_t p_len); - Map remaps; + HashMap remaps; Error error = OK; ResourceFormatLoader::CacheMode cache_mode = ResourceFormatLoader::CACHE_MODE_REUSE; @@ -89,7 +89,7 @@ class ResourceLoaderBinary { Error parse_variant(Variant &r_v); - Map> dependency_cache; + HashMap> dependency_cache; public: void set_local_path(const String &p_local_path); @@ -97,7 +97,7 @@ class ResourceLoaderBinary { Error load(); void set_translation_remapped(bool p_remapped); - void set_remaps(const Map &p_remaps) { remaps = p_remaps; } + void set_remaps(const HashMap &p_remaps) { remaps = p_remaps; } void open(Ref p_f, bool p_no_resources = false, bool p_keep_uuid_paths = false); String recognize(Ref p_f); void get_dependencies(Ref p_f, List *p_dependencies, bool p_add_types); @@ -114,7 +114,7 @@ class ResourceFormatLoaderBinary : public ResourceFormatLoader { virtual String get_resource_type(const String &p_path) const; virtual ResourceUID::ID get_resource_uid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types = false); - virtual Error rename_dependencies(const String &p_path, const Map &p_map); + virtual Error rename_dependencies(const String &p_path, const HashMap &p_map); }; class ResourceFormatSaverBinaryInstance { @@ -127,7 +127,7 @@ class ResourceFormatSaverBinaryInstance { bool big_endian; bool takeover_paths; String magic; - Set> resource_set; + RBSet> resource_set; struct NonPersistentKey { //for resource properties generated on the fly Ref base; @@ -135,11 +135,11 @@ class ResourceFormatSaverBinaryInstance { bool operator<(const NonPersistentKey &p_key) const { return base == p_key.base ? property < p_key.property : base < p_key.base; } }; - Map> non_persistent_map; - Map string_map; + RBMap> non_persistent_map; + HashMap string_map; Vector strings; - Map, int> external_resources; + HashMap, int> external_resources; List> saved_resources; struct Property { @@ -168,7 +168,7 @@ class ResourceFormatSaverBinaryInstance { RESERVED_FIELDS = 11 }; Error save(const String &p_path, const Ref &p_resource, uint32_t p_flags = 0); - static void write_variant(Ref f, const Variant &p_property, Map, int> &resource_map, Map, int> &external_resources, Map &string_map, const PropertyInfo &p_hint = PropertyInfo()); + static void write_variant(Ref f, const Variant &p_property, HashMap, int> &resource_map, HashMap, int> &external_resources, HashMap &string_map, const PropertyInfo &p_hint = PropertyInfo()); }; class ResourceFormatSaverBinary : public ResourceFormatSaver { diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index 984cf06d2b7f..5deee9721bda 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -139,7 +139,7 @@ Ref ResourceFormatImporter::load(const String &p_path, const String &p } void ResourceFormatImporter::get_recognized_extensions(List *p_extensions) const { - Set found; + RBSet found; for (int i = 0; i < importers.size(); i++) { List local_exts; @@ -159,7 +159,7 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ return; } - Set found; + RBSet found; for (int i = 0; i < importers.size(); i++) { String res_type = importers[i]->get_resource_type(); diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h index b3d777847b1c..0c7909df0615 100644 --- a/core/io/resource_importer.h +++ b/core/io/resource_importer.h @@ -134,15 +134,15 @@ class ResourceImporter : public RefCounted { virtual String get_preset_name(int p_idx) const { return String(); } virtual void get_import_options(const String &p_path, List *r_options, int p_preset = 0) const = 0; - virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map &p_options) const = 0; + virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap &p_options) const = 0; virtual String get_option_group_file() const { return String(); } - virtual Error import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files = nullptr, Variant *r_metadata = nullptr) = 0; + virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files = nullptr, Variant *r_metadata = nullptr) = 0; virtual bool can_import_threaded() const { return true; } virtual void import_threaded_begin() {} virtual void import_threaded_end() {} - virtual Error import_group_file(const String &p_group_file, const Map> &p_source_file_options, const Map &p_base_paths) { return ERR_UNAVAILABLE; } + virtual Error import_group_file(const String &p_group_file, const HashMap> &p_source_file_options, const HashMap &p_base_paths) { return ERR_UNAVAILABLE; } virtual bool are_import_settings_valid(const String &p_path) const { return true; } virtual String get_import_settings_string() const { return String(); } }; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index d125dd4e9129..9e6330f34bbb 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -154,7 +154,7 @@ void ResourceFormatLoader::get_dependencies(const String &p_path, List * } } -Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Map &p_map) { +Error ResourceFormatLoader::rename_dependencies(const String &p_path, const HashMap &p_map) { Dictionary deps_dict; for (KeyValue E : p_map) { deps_dict[E.key] = E.value; @@ -391,7 +391,7 @@ float ResourceLoader::_dependency_get_progress(const String &p_path) { int dep_count = load_task.sub_tasks.size(); if (dep_count > 0) { float dep_progress = 0; - for (Set::Element *E = load_task.sub_tasks.front(); E; E = E->next()) { + for (RBSet::Element *E = load_task.sub_tasks.front(); E; E = E->next()) { dep_progress += _dependency_get_progress(E->get()); } dep_progress /= float(dep_count); @@ -733,7 +733,7 @@ void ResourceLoader::get_dependencies(const String &p_path, List *p_depe } } -Error ResourceLoader::rename_dependencies(const String &p_path, const Map &p_map) { +Error ResourceLoader::rename_dependencies(const String &p_path, const HashMap &p_map) { String local_path = _path_remap(_validate_local_path(p_path)); for (int i = 0; i < loader_count; i++) { diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index ea18ac23fdcf..e189ad1dff70 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -70,7 +70,7 @@ class ResourceFormatLoader : public RefCounted { virtual String get_resource_type(const String &p_path) const; virtual ResourceUID::ID get_resource_uid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types = false); - virtual Error rename_dependencies(const String &p_path, const Map &p_map); + virtual Error rename_dependencies(const String &p_path, const HashMap &p_map); virtual bool is_import_valid(const String &p_path) const { return true; } virtual bool is_imported(const String &p_path) const { return false; } virtual int get_import_order(const String &p_path) const { return 0; } @@ -145,7 +145,7 @@ class ResourceLoader { bool start_next = true; int requests = 0; int poll_requests = 0; - Set sub_tasks; + RBSet sub_tasks; }; static void _thread_load_function(void *p_userdata); @@ -173,7 +173,7 @@ class ResourceLoader { static String get_resource_type(const String &p_path); static ResourceUID::ID get_resource_uid(const String &p_path); static void get_dependencies(const String &p_path, List *p_dependencies, bool p_add_types = false); - static Error rename_dependencies(const String &p_path, const Map &p_map); + static Error rename_dependencies(const String &p_path, const HashMap &p_map); static bool is_import_valid(const String &p_path); static String get_import_group_file(const String &p_path); static bool is_imported(const String &p_path); diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 284b4294ea7e..a3ee259030b7 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -151,7 +151,7 @@ void AStar3D::connect_points(int p_id, int p_with_id, bool bidirectional) { s.direction = Segment::BIDIRECTIONAL; } - Set::Element *element = segments.find(s); + RBSet::Element *element = segments.find(s); if (element != nullptr) { s.direction |= element->get().direction; if (s.direction == Segment::BIDIRECTIONAL) { @@ -177,7 +177,7 @@ void AStar3D::disconnect_points(int p_id, int p_with_id, bool bidirectional) { Segment s(p_id, p_with_id); int remove_direction = bidirectional ? (int)Segment::BIDIRECTIONAL : s.direction; - Set::Element *element = segments.find(s); + RBSet::Element *element = segments.find(s); if (element != nullptr) { // s is the new segment // Erase the directions to be removed @@ -235,7 +235,7 @@ Vector AStar3D::get_point_connections(int p_id) { bool AStar3D::are_points_connected(int p_id, int p_with_id, bool bidirectional) const { Segment s(p_id, p_with_id); - const Set::Element *element = segments.find(s); + const RBSet::Element *element = segments.find(s); return element != nullptr && (bidirectional || (element->get().direction & s.direction) == s.direction); @@ -293,7 +293,7 @@ Vector3 AStar3D::get_closest_position_in_segment(const Vector3 &p_point) const { real_t closest_dist = 1e20; Vector3 closest_point; - for (const Set::Element *E = segments.front(); E; E = E->next()) { + for (const RBSet::Element *E = segments.front(); E; E = E->next()) { Point *from_point = nullptr, *to_point = nullptr; points.lookup(E->get().u, from_point); points.lookup(E->get().v, to_point); diff --git a/core/math/a_star.h b/core/math/a_star.h index bb7112fb0906..086be839b549 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -112,7 +112,7 @@ class AStar3D : public RefCounted { uint64_t pass = 1; OAHashMap points; - Set segments; + RBSet segments; bool _solve(Point *begin_point, Point *end_point); diff --git a/core/math/color.cpp b/core/math/color.cpp index e32f9147d9d1..74552a289482 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -33,7 +33,7 @@ #include "color_names.inc" #include "core/math/math_funcs.h" #include "core/string/print_string.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" uint32_t Color::to_argb32() const { uint32_t c = (uint8_t)Math::round(a * 255); diff --git a/core/math/disjoint_set.h b/core/math/disjoint_set.h index 8657dc068e3c..d07c08e45e43 100644 --- a/core/math/disjoint_set.h +++ b/core/math/disjoint_set.h @@ -31,11 +31,11 @@ #ifndef DISJOINT_SET_H #define DISJOINT_SET_H -#include "core/templates/map.h" +#include "core/templates/rb_map.h" #include "core/templates/vector.h" /* This DisjointSet class uses Find with path compression and Union by rank */ -template , class AL = DefaultAllocator> +template , class AL = DefaultAllocator> class DisjointSet { struct Element { T object; @@ -43,7 +43,7 @@ class DisjointSet { int rank = 0; }; - typedef Map MapT; + typedef HashMap MapT; MapT elements; @@ -65,15 +65,15 @@ class DisjointSet { /* FUNCTIONS */ -template -DisjointSet::~DisjointSet() { - for (typename MapT::Element *itr = elements.front(); itr != nullptr; itr = itr->next()) { - memdelete_allocator(itr->value()); +template +DisjointSet::~DisjointSet() { + for (KeyValue &E : elements) { + memdelete_allocator(E.value); } } -template -typename DisjointSet::Element *DisjointSet::get_parent(Element *element) { +template +typename DisjointSet::Element *DisjointSet::get_parent(Element *element) { if (element->parent != element) { element->parent = get_parent(element->parent); } @@ -81,11 +81,11 @@ typename DisjointSet::Element *DisjointSet::get_parent(Eleme return element->parent; } -template -typename DisjointSet::Element *DisjointSet::insert_or_get(T object) { - typename MapT::Element *itr = elements.find(object); +template +typename DisjointSet::Element *DisjointSet::insert_or_get(T object) { + typename MapT::Iterator itr = elements.find(object); if (itr != nullptr) { - return itr->value(); + return itr->value; } Element *new_element = memnew_allocator(Element, AL); @@ -96,8 +96,8 @@ typename DisjointSet::Element *DisjointSet::insert_or_get(T return new_element; } -template -void DisjointSet::create_union(T a, T b) { +template +void DisjointSet::create_union(T a, T b) { Element *x = insert_or_get(a); Element *y = insert_or_get(b); @@ -121,28 +121,28 @@ void DisjointSet::create_union(T a, T b) { } } -template -void DisjointSet::get_representatives(Vector &out_representatives) { - for (typename MapT::Element *itr = elements.front(); itr != nullptr; itr = itr->next()) { - Element *element = itr->value(); +template +void DisjointSet::get_representatives(Vector &out_representatives) { + for (KeyValue &E : elements) { + Element *element = E.value; if (element->parent == element) { out_representatives.push_back(element->object); } } } -template -void DisjointSet::get_members(Vector &out_members, T representative) { - typename MapT::Element *rep_itr = elements.find(representative); +template +void DisjointSet::get_members(Vector &out_members, T representative) { + typename MapT::Iterator rep_itr = elements.find(representative); ERR_FAIL_COND(rep_itr == nullptr); - Element *rep_element = rep_itr->value(); + Element *rep_element = rep_itr->value; ERR_FAIL_COND(rep_element->parent != rep_element); - for (typename MapT::Element *itr = elements.front(); itr != nullptr; itr = itr->next()) { - Element *parent = get_parent(itr->value()); + for (KeyValue &E : elements) { + Element *parent = get_parent(E.value); if (parent == rep_element) { - out_members.push_back(itr->key()); + out_members.push_back(E.key); } } } diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index f76de079e48c..ec96753c7921 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -36,7 +36,7 @@ #include "thirdparty/misc/polypartition.h" void Geometry3D::MeshData::optimize_vertices() { - Map vtx_remap; + HashMap vtx_remap; for (int i = 0; i < faces.size(); i++) { for (int j = 0; j < faces[i].indices.size(); j++) { diff --git a/core/math/octree.h b/core/math/octree.h index 65ab9e2292e5..8dd103f1090e 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -36,7 +36,7 @@ #include "core/math/vector3.h" #include "core/string/print_string.h" #include "core/templates/list.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" #include "core/variant/variant.h" typedef uint32_t OctreeElementID; @@ -151,8 +151,8 @@ class Octree { typename List::Element *eA, *eB; }; - typedef Map, AL> ElementMap; - typedef Map, AL> PairMap; + typedef HashMap, AL> ElementMap; + typedef HashMap, AL> PairMap; ElementMap element_map; PairMap pair_map; diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 3614bfadf843..43744deeb0d1 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -30,7 +30,7 @@ #include "quick_hull.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" uint32_t QuickHull::debug_stop_after = 0xFFFFFFFF; @@ -52,7 +52,7 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ Vector valid_points; valid_points.resize(p_points.size()); - Set valid_cache; + RBSet valid_cache; for (int i = 0; i < p_points.size(); i++) { Vector3 sp = p_points[i].snapped(Vector3(0.0001, 0.0001, 0.0001)); @@ -237,7 +237,7 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ //find lit faces and lit edges List::Element *> lit_faces; //lit face is a death sentence - Map lit_edges; //create this on the flight, should not be that bad for performance and simplifies code a lot + HashMap lit_edges; //create this on the flight, should not be that bad for performance and simplifies code a lot for (List::Element *E = faces.front(); E; E = E->next()) { if (E->get().plane.distance_to(v) > 0) { @@ -248,15 +248,15 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ uint32_t b = E->get().vertices[(i + 1) % 3]; Edge e(a, b); - Map::Element *F = lit_edges.find(e); + HashMap::Iterator F = lit_edges.find(e); if (!F) { F = lit_edges.insert(e, FaceConnect()); } if (e.vertices[0] == a) { //left - F->get().left = E; + F->value.left = E; } else { - F->get().right = E; + F->value.right = E; } } } @@ -333,7 +333,7 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ /* CREATE MESHDATA */ //make a map of edges again - Map ret_edges; + HashMap ret_edges; List ret_faces; for (const Face &E : faces) { @@ -351,15 +351,15 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ uint32_t b = E.vertices[(i + 1) % 3]; Edge e(a, b); - Map::Element *G = ret_edges.find(e); + HashMap::Iterator G = ret_edges.find(e); if (!G) { G = ret_edges.insert(e, RetFaceConnect()); } if (e.vertices[0] == a) { //left - G->get().left = F; + G->value.left = F; } else { - G->get().right = F; + G->value.right = F; } } } @@ -374,10 +374,10 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ int b = E->get().indices[(i + 1) % f.indices.size()]; Edge e(a, b); - Map::Element *F = ret_edges.find(e); + HashMap::Iterator F = ret_edges.find(e); ERR_CONTINUE(!F); - List::Element *O = F->get().left == E ? F->get().right : F->get().left; + List::Element *O = F->value.left == E ? F->value.right : F->value.left; ERR_CONTINUE(O == E); ERR_CONTINUE(O == nullptr); @@ -401,13 +401,13 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ } Edge e2(idx, idxn); - Map::Element *F2 = ret_edges.find(e2); + HashMap::Iterator F2 = ret_edges.find(e2); ERR_CONTINUE(!F2); //change faceconnect, point to this face instead - if (F2->get().left == O) { - F2->get().left = E; - } else if (F2->get().right == O) { - F2->get().right = E; + if (F2->value.left == O) { + F2->value.left = E; + } else if (F2->value.right == O) { + F2->value.right = E; } } @@ -426,7 +426,7 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ } } - ret_edges.erase(F); //remove the edge + ret_edges.remove(F); //remove the edge ret_faces.erase(O); //remove the face } } diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index b8d813c9795c..1c354880b465 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -34,7 +34,7 @@ #include "core/math/aabb.h" #include "core/math/geometry_3d.h" #include "core/templates/list.h" -#include "core/templates/set.h" +#include "core/templates/rb_set.h" class QuickHull { public: @@ -44,9 +44,16 @@ class QuickHull { uint64_t id = 0; }; + static uint32_t hash(const Edge &p_edge) { + return hash_one_uint64(p_edge.id); + } + bool operator<(const Edge &p_edge) const { return id < p_edge.id; } + bool operator==(const Edge &p_edge) const { + return id == p_edge.id; + } Edge(int p_vtx_a = 0, int p_vtx_b = 0) { if (p_vtx_a > p_vtx_b) { diff --git a/core/math/static_raycaster.h b/core/math/static_raycaster.h index 33254399c78a..adc81906d74e 100644 --- a/core/math/static_raycaster.h +++ b/core/math/static_raycaster.h @@ -102,7 +102,7 @@ class StaticRaycaster : public RefCounted { virtual void add_mesh(const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices, unsigned int p_id) = 0; virtual void commit() = 0; - virtual void set_mesh_filter(const Set &p_mesh_ids) = 0; + virtual void set_mesh_filter(const RBSet &p_mesh_ids) = 0; virtual void clear_mesh_filter() = 0; static Ref create(); diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index e146c4a4e311..54461bf70f51 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -122,7 +122,7 @@ void TriangleMesh::create(const Vector &p_faces) { const Vector3 *r = p_faces.ptr(); Triangle *w = triangles.ptrw(); - Map db; + HashMap db; for (int i = 0; i < fc; i++) { Triangle &f = w[i]; @@ -131,9 +131,9 @@ void TriangleMesh::create(const Vector &p_faces) { for (int j = 0; j < 3; j++) { int vidx = -1; Vector3 vs = v[j].snapped(Vector3(0.0001, 0.0001, 0.0001)); - Map::Element *E = db.find(vs); + HashMap::Iterator E = db.find(vs); if (E) { - vidx = E->get(); + vidx = E->value; } else { vidx = db.size(); db[vs] = vidx; diff --git a/core/multiplayer/multiplayer_api.cpp b/core/multiplayer/multiplayer_api.cpp index 3533acd103df..e18c3dd2e434 100644 --- a/core/multiplayer/multiplayer_api.cpp +++ b/core/multiplayer/multiplayer_api.cpp @@ -494,7 +494,7 @@ Vector MultiplayerAPI::get_peer_ids() const { ERR_FAIL_COND_V_MSG(!multiplayer_peer.is_valid(), Vector(), "No multiplayer peer is assigned. Assume no peers are connected."); Vector ret; - for (Set::Element *E = connected_peers.front(); E; E = E->next()) { + for (RBSet::Element *E = connected_peers.front(); E; E = E->next()) { ret.push_back(E->get()); } diff --git a/core/multiplayer/multiplayer_api.h b/core/multiplayer/multiplayer_api.h index 9fe67615e3b0..b93f2acbd3ab 100644 --- a/core/multiplayer/multiplayer_api.h +++ b/core/multiplayer/multiplayer_api.h @@ -113,7 +113,7 @@ class MultiplayerAPI : public RefCounted { private: Ref multiplayer_peer; - Set connected_peers; + RBSet connected_peers; int remote_sender_id = 0; int remote_sender_override = 0; @@ -172,7 +172,7 @@ class MultiplayerAPI : public RefCounted { bool has_multiplayer_peer() const { return multiplayer_peer.is_valid(); } Vector get_peer_ids() const; - const Set get_connected_peers() const { return connected_peers; } + const RBSet get_connected_peers() const { return connected_peers; } int get_remote_sender_id() const { return remote_sender_override ? remote_sender_override : remote_sender_id; } void set_remote_sender_override(int p_id) { remote_sender_override = p_id; } int get_unique_id() const; diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index d0fcde832bf8..d19cbf2642e1 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -1390,7 +1390,7 @@ void ClassDB::get_extensions_for_type(const StringName &p_class, List *p } HashMap> ClassDB::default_values; -Set ClassDB::default_values_cached; +RBSet ClassDB::default_values_cached; Variant ClassDB::class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid) { if (!default_values_cached.has(p_class)) { @@ -1492,7 +1492,7 @@ void ClassDB::unregister_extension_class(const StringName &p_class) { classes.erase(p_class); } -Map ClassDB::native_structs; +HashMap ClassDB::native_structs; void ClassDB::register_native_struct(const StringName &p_name, const String &p_code, uint64_t p_current_size) { NativeStruct ns; ns.ccode = p_code; diff --git a/core/object/class_db.h b/core/object/class_db.h index d4e1fc4e76be..67b71ab05826 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -110,10 +110,10 @@ class ClassDB { #ifdef DEBUG_METHODS_ENABLED List constant_order; List method_order; - Set methods_in_properties; + RBSet methods_in_properties; List virtual_methods; - Map virtual_methods_map; - Map> method_error_values; + HashMap virtual_methods_map; + HashMap> method_error_values; #endif HashMap property_setget; @@ -149,14 +149,14 @@ class ClassDB { static void _add_class2(const StringName &p_class, const StringName &p_inherits); static HashMap> default_values; - static Set default_values_cached; + static RBSet default_values_cached; // Native structs, used by binder struct NativeStruct { String ccode; // C code to create the native struct, fields separated by ; Arrays accepted (even containing other structs), also function pointers. All types must be Godot types. uint64_t struct_size; // local size of struct, for comparison }; - static Map native_structs; + static HashMap native_structs; private: // Non-locking variants of get_parent_class and is_parent_class. diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp index 79c36ac81f53..fa1945cf799d 100644 --- a/core/object/message_queue.cpp +++ b/core/object/message_queue.cpp @@ -142,9 +142,9 @@ Error MessageQueue::push_callablep(const Callable &p_callable, const Variant **p } void MessageQueue::statistics() { - Map set_count; - Map notify_count; - Map call_count; + HashMap set_count; + HashMap notify_count; + HashMap call_count; int null_count = 0; uint32_t read_pos = 0; diff --git a/core/object/object.cpp b/core/object/object.cpp index 797eecd3122e..0912ea55f084 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -1382,8 +1382,6 @@ bool Object::is_connected(const StringName &p_signal, const Callable &p_callable Callable target = p_callable; return s->slot_map.has(*target.get_base_comparator()); - //const Map::Element *E = s->slot_map.find(target); - //return (E!=nullptr ); } void Object::disconnect(const StringName &p_signal, const Callable &p_callable) { diff --git a/core/object/object.h b/core/object/object.h index 00cb73593bbb..ca7b9965f18d 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -38,9 +38,9 @@ #include "core/os/spin_lock.h" #include "core/templates/hash_map.h" #include "core/templates/list.h" -#include "core/templates/map.h" +#include "core/templates/rb_map.h" +#include "core/templates/rb_set.h" #include "core/templates/safe_refcount.h" -#include "core/templates/set.h" #include "core/templates/vmap.h" #include "core/variant/callable_bind.h" #include "core/variant/variant.h" @@ -510,7 +510,7 @@ class Object { #ifdef TOOLS_ENABLED bool _edited = false; uint32_t _edited_version = 0; - Set editor_section_folding; + RBSet editor_section_folding; #endif ScriptInstance *script_instance = nullptr; Variant script; // Reference does not exist yet, store it in a Variant. @@ -815,7 +815,7 @@ class Object { #ifdef TOOLS_ENABLED void editor_set_section_unfold(const String &p_section, bool p_unfolded); bool editor_is_section_unfolded(const String &p_section); - const Set &editor_get_section_folding() const { return editor_section_folding; } + const RBSet &editor_get_section_folding() const { return editor_section_folding; } void editor_clear_section_folding() { editor_section_folding.clear(); } #endif diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index c1036e3413c4..1546d52fd284 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -93,7 +93,7 @@ Array Script::_get_script_signal_list() { Dictionary Script::_get_script_constant_map() { Dictionary ret; - Map map; + HashMap map; get_constants(&map); for (const KeyValue &E : map) { ret[E.key] = E.value; @@ -474,8 +474,8 @@ bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const { return false; } -void PlaceHolderScriptInstance::update(const List &p_properties, const Map &p_values) { - Set new_values; +void PlaceHolderScriptInstance::update(const List &p_properties, const HashMap &p_values) { + RBSet new_values; for (const PropertyInfo &E : p_properties) { StringName n = E.name; new_values.insert(n); @@ -490,16 +490,16 @@ void PlaceHolderScriptInstance::update(const List &p_properties, c properties = p_properties; List to_remove; - for (Map::Element *E = values.front(); E; E = E->next()) { - if (!new_values.has(E->key())) { - to_remove.push_back(E->key()); + for (KeyValue &E : values) { + if (!new_values.has(E.key)) { + to_remove.push_back(E.key); } Variant defval; - if (script->get_property_default_value(E->key(), defval)) { + if (script->get_property_default_value(E.key, defval)) { //remove because it's the same as the default value - if (defval == E->get()) { - to_remove.push_back(E->key()); + if (defval == E.value) { + to_remove.push_back(E.key); } } } @@ -520,10 +520,10 @@ void PlaceHolderScriptInstance::update(const List &p_properties, c void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid) { if (script->is_placeholder_fallback_enabled()) { - Map::Element *E = values.find(p_name); + HashMap::Iterator E = values.find(p_name); if (E) { - E->value() = p_value; + E->value = p_value; } else { values.insert(p_name, p_value); } @@ -547,13 +547,13 @@ void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, Variant PlaceHolderScriptInstance::property_get_fallback(const StringName &p_name, bool *r_valid) { if (script->is_placeholder_fallback_enabled()) { - const Map::Element *E = values.find(p_name); + HashMap::ConstIterator E = values.find(p_name); if (E) { if (r_valid) { *r_valid = true; } - return E->value(); + return E->value; } E = constants.find(p_name); @@ -561,7 +561,7 @@ Variant PlaceHolderScriptInstance::property_get_fallback(const StringName &p_nam if (r_valid) { *r_valid = true; } - return E->value(); + return E->value; } } diff --git a/core/object/script_language.h b/core/object/script_language.h index bd87427eaf25..b1481a372e70 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -34,8 +34,8 @@ #include "core/doc_data.h" #include "core/io/resource.h" #include "core/multiplayer/multiplayer.h" -#include "core/templates/map.h" #include "core/templates/pair.h" +#include "core/templates/rb_map.h" class ScriptLanguage; @@ -154,8 +154,8 @@ class Script : public Resource { virtual int get_member_line(const StringName &p_member) const { return -1; } - virtual void get_constants(Map *p_constants) {} - virtual void get_members(Set *p_constants) {} + virtual void get_constants(HashMap *p_constants) {} + virtual void get_members(RBSet *p_constants) {} virtual bool is_placeholder_fallback_enabled() const { return false; } @@ -283,7 +283,7 @@ class ScriptLanguage : public Object { virtual Ref