1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

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!
This commit is contained in:
reduz
2022-05-13 15:04:37 +02:00
committed by Rémi Verschelde
parent 396def9b66
commit 746dddc067
587 changed files with 3707 additions and 3538 deletions

View File

@@ -35,7 +35,7 @@
#include "core/string/string_name.h"
#include "core/string/ustring.h"
#include "core/templates/list.h"
#include "core/templates/map.h"
#include "core/templates/rb_map.h"
#include "core/typedefs.h"
#include "core/variant/variant.h"
@@ -525,7 +525,7 @@ public:
ConstantNode::Value value;
};
Map<StringName, Variable> variables;
HashMap<StringName, Variable> variables;
List<Node *> statements;
bool single_statement = false;
bool use_comma_between_statements = false;
@@ -589,7 +589,7 @@ public:
bool is_const;
int array_size;
Map<StringName, Set<int>> tex_argument_connect;
HashMap<StringName, RBSet<int>> tex_argument_connect;
};
StringName name;
@@ -622,7 +622,7 @@ public:
struct Function {
StringName name;
FunctionNode *function = nullptr;
Set<StringName> uses_function;
RBSet<StringName> uses_function;
bool callable;
};
@@ -697,10 +697,10 @@ public:
}
};
Map<StringName, Constant> constants;
Map<StringName, Varying> varyings;
Map<StringName, Uniform> uniforms;
Map<StringName, Struct> structs;
HashMap<StringName, Constant> constants;
HashMap<StringName, Varying> varyings;
HashMap<StringName, Uniform> uniforms;
HashMap<StringName, Struct> structs;
Vector<StringName> render_modes;
Vector<Function> functions;
@@ -857,13 +857,13 @@ public:
};
struct FunctionInfo {
Map<StringName, BuiltInInfo> built_ins;
Map<StringName, StageFunctionInfo> stage_functions;
HashMap<StringName, BuiltInInfo> built_ins;
HashMap<StringName, StageFunctionInfo> stage_functions;
bool can_discard = false;
bool main_function = false;
};
static bool has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name);
static bool has_builtin(const HashMap<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name);
typedef DataType (*GlobalVariableGetTypeFunc)(const StringName &p_name);
@@ -893,15 +893,15 @@ private:
}
};
Map<StringName, Usage> used_constants;
Map<StringName, Usage> used_varyings;
Map<StringName, Usage> used_uniforms;
Map<StringName, Usage> used_functions;
Map<StringName, Usage> used_structs;
Map<ShaderWarning::Code, Map<StringName, Usage> *> warnings_check_map;
HashMap<StringName, Usage> used_constants;
HashMap<StringName, Usage> used_varyings;
HashMap<StringName, Usage> used_uniforms;
HashMap<StringName, Usage> used_functions;
HashMap<StringName, Usage> used_structs;
HashMap<ShaderWarning::Code, HashMap<StringName, Usage> *> warnings_check_map;
Map<StringName, Map<StringName, Usage>> used_local_vars;
Map<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *> warnings_check_map2;
HashMap<StringName, HashMap<StringName, Usage>> used_local_vars;
HashMap<ShaderWarning::Code, HashMap<StringName, HashMap<StringName, Usage>> *> warnings_check_map2;
List<ShaderWarning> warnings;
@@ -1039,7 +1039,7 @@ private:
uint32_t keyword_completion_context;
#endif // DEBUG_ENABLED
const Map<StringName, FunctionInfo> *stages = nullptr;
const HashMap<StringName, FunctionInfo> *stages = nullptr;
bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier);
static const BuiltinFuncDef builtin_func_defs[];
@@ -1068,10 +1068,10 @@ private:
Node *_parse_and_reduce_expression(BlockNode *p_block, const FunctionInfo &p_function_info);
Error _parse_block(BlockNode *p_block, const FunctionInfo &p_function_info, bool p_just_one = false, bool p_can_break = false, bool p_can_continue = false);
String _get_shader_type_list(const Set<String> &p_shader_types) const;
String _get_shader_type_list(const RBSet<String> &p_shader_types) const;
String _get_qualifier_str(ArgumentQualifier p_qualifier) const;
Error _parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const Set<String> &p_shader_types);
Error _parse_shader(const HashMap<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const RBSet<String> &p_shader_types);
Error _find_last_flow_op_in_block(BlockNode *p_block, FlowOperation p_op);
Error _find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOperation p_op);
@@ -1094,10 +1094,10 @@ public:
static String get_shader_type(const String &p_code);
struct ShaderCompileInfo {
Map<StringName, FunctionInfo> functions;
HashMap<StringName, FunctionInfo> functions;
Vector<ModeInfo> render_modes;
VaryingFunctionNames varying_function_names = VaryingFunctionNames();
Set<String> shader_types;
RBSet<String> shader_types;
GlobalVariableGetTypeFunc global_variable_type_func = nullptr;
};