mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 06:01:14 +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:
parent
396def9b66
commit
746dddc067
587 changed files with 3707 additions and 3538 deletions
|
|
@ -4019,7 +4019,7 @@ uint32_t ShaderLanguage::get_datatype_size(ShaderLanguage::DataType p_type) {
|
|||
}
|
||||
|
||||
void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
|
||||
Set<String> kws;
|
||||
RBSet<String> kws;
|
||||
|
||||
int idx = 0;
|
||||
|
||||
|
|
@ -4036,7 +4036,7 @@ void ShaderLanguage::get_keyword_list(List<String> *r_keywords) {
|
|||
idx++;
|
||||
}
|
||||
|
||||
for (Set<String>::Element *E = kws.front(); E; E = E->next()) {
|
||||
for (RBSet<String>::Element *E = kws.front(); E; E = E->next()) {
|
||||
r_keywords->push_back(E->get());
|
||||
}
|
||||
}
|
||||
|
|
@ -4056,7 +4056,7 @@ bool ShaderLanguage::is_control_flow_keyword(String p_keyword) {
|
|||
}
|
||||
|
||||
void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) {
|
||||
Set<String> kws;
|
||||
RBSet<String> kws;
|
||||
|
||||
int idx = 0;
|
||||
|
||||
|
|
@ -4066,7 +4066,7 @@ void ShaderLanguage::get_builtin_funcs(List<String> *r_keywords) {
|
|||
idx++;
|
||||
}
|
||||
|
||||
for (Set<String>::Element *E = kws.front(); E; E = E->next()) {
|
||||
for (RBSet<String>::Element *E = kws.front(); E; E = E->next()) {
|
||||
r_keywords->push_back(E->get());
|
||||
}
|
||||
}
|
||||
|
|
@ -4340,8 +4340,8 @@ bool ShaderLanguage::_propagate_function_call_sampler_uniform_settings(StringNam
|
|||
arg->tex_argument_check = true;
|
||||
arg->tex_argument_filter = p_filter;
|
||||
arg->tex_argument_repeat = p_repeat;
|
||||
for (KeyValue<StringName, Set<int>> &E : arg->tex_argument_connect) {
|
||||
for (Set<int>::Element *F = E.value.front(); F; F = F->next()) {
|
||||
for (KeyValue<StringName, RBSet<int>> &E : arg->tex_argument_connect) {
|
||||
for (RBSet<int>::Element *F = E.value.front(); F; F = F->next()) {
|
||||
if (!_propagate_function_call_sampler_uniform_settings(E.key, F->get(), p_filter, p_repeat)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -4374,8 +4374,8 @@ bool ShaderLanguage::_propagate_function_call_sampler_builtin_reference(StringNa
|
|||
arg->tex_builtin_check = true;
|
||||
arg->tex_builtin = p_builtin;
|
||||
|
||||
for (KeyValue<StringName, Set<int>> &E : arg->tex_argument_connect) {
|
||||
for (Set<int>::Element *F = E.value.front(); F; F = F->next()) {
|
||||
for (KeyValue<StringName, RBSet<int>> &E : arg->tex_argument_connect) {
|
||||
for (RBSet<int>::Element *F = E.value.front(); F; F = F->next()) {
|
||||
if (!_propagate_function_call_sampler_builtin_reference(E.key, F->get(), p_builtin)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -5096,7 +5096,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
|||
for (int j = 0; j < base_function->arguments.size(); j++) {
|
||||
if (base_function->arguments[j].name == varname) {
|
||||
if (!base_function->arguments[j].tex_argument_connect.has(call_function->name)) {
|
||||
base_function->arguments.write[j].tex_argument_connect[call_function->name] = Set<int>();
|
||||
base_function->arguments.write[j].tex_argument_connect[call_function->name] = RBSet<int>();
|
||||
}
|
||||
base_function->arguments.write[j].tex_argument_connect[call_function->name].insert(i);
|
||||
found = true;
|
||||
|
|
@ -5419,9 +5419,9 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
|||
StringName member_struct_name = "";
|
||||
int array_size = 0;
|
||||
|
||||
Set<char> position_symbols;
|
||||
Set<char> color_symbols;
|
||||
Set<char> texture_symbols;
|
||||
RBSet<char> position_symbols;
|
||||
RBSet<char> color_symbols;
|
||||
RBSet<char> texture_symbols;
|
||||
|
||||
bool mix_error = false;
|
||||
|
||||
|
|
@ -6648,7 +6648,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
|
|||
StringName func_name = parent_function->name;
|
||||
|
||||
if (!used_local_vars.has(func_name)) {
|
||||
used_local_vars.insert(func_name, Map<StringName, Usage>());
|
||||
used_local_vars.insert(func_name, HashMap<StringName, Usage>());
|
||||
}
|
||||
|
||||
used_local_vars[func_name].insert(name, Usage(tk_line));
|
||||
|
|
@ -7062,7 +7062,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
|
|||
_set_tkpos(pos);
|
||||
continue;
|
||||
} else {
|
||||
Set<int> constants;
|
||||
RBSet<int> constants;
|
||||
for (int i = 0; i < switch_block->statements.size(); i++) { // Checks for duplicates.
|
||||
ControlFlowNode *flow = static_cast<ControlFlowNode *>(switch_block->statements[i]);
|
||||
if (flow) {
|
||||
|
|
@ -7565,10 +7565,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
|
|||
return OK;
|
||||
}
|
||||
|
||||
String ShaderLanguage::_get_shader_type_list(const Set<String> &p_shader_types) const {
|
||||
String ShaderLanguage::_get_shader_type_list(const RBSet<String> &p_shader_types) const {
|
||||
// Return a list of shader types as an human-readable string
|
||||
String valid_types;
|
||||
for (const Set<String>::Element *E = p_shader_types.front(); E; E = E->next()) {
|
||||
for (const RBSet<String>::Element *E = p_shader_types.front(); E; E = E->next()) {
|
||||
if (!valid_types.is_empty()) {
|
||||
valid_types += ", ";
|
||||
}
|
||||
|
|
@ -7639,7 +7639,7 @@ Error ShaderLanguage::_validate_datatype(DataType p_type) {
|
|||
return OK;
|
||||
}
|
||||
|
||||
Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const Set<String> &p_shader_types) {
|
||||
Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_functions, const Vector<ModeInfo> &p_render_modes, const RBSet<String> &p_shader_types) {
|
||||
Token tk = _get_token();
|
||||
TkPos prev_pos;
|
||||
Token next;
|
||||
|
|
@ -7699,7 +7699,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
|||
stages = &p_functions;
|
||||
const FunctionInfo &constants = p_functions.has("constants") ? p_functions["constants"] : FunctionInfo();
|
||||
|
||||
Map<String, String> defined_modes;
|
||||
HashMap<String, String> defined_modes;
|
||||
|
||||
while (tk.type != TK_EOF) {
|
||||
switch (tk.type) {
|
||||
|
|
@ -7790,7 +7790,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
|||
st.shader_struct = st_node;
|
||||
|
||||
int member_count = 0;
|
||||
Set<String> member_names;
|
||||
RBSet<String> member_names;
|
||||
|
||||
while (true) { // variables list
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
|
@ -9234,7 +9234,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
|||
return OK;
|
||||
}
|
||||
|
||||
bool ShaderLanguage::has_builtin(const Map<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) {
|
||||
bool ShaderLanguage::has_builtin(const HashMap<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name) {
|
||||
for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : p_functions) {
|
||||
if (E.value.built_ins.has(p_name)) {
|
||||
return true;
|
||||
|
|
@ -9376,19 +9376,19 @@ String ShaderLanguage::get_shader_type(const String &p_code) {
|
|||
|
||||
#ifdef DEBUG_ENABLED
|
||||
void ShaderLanguage::_check_warning_accums() {
|
||||
for (const KeyValue<ShaderWarning::Code, Map<StringName, Map<StringName, Usage>> *> &E : warnings_check_map2) {
|
||||
for (Map<StringName, Map<StringName, Usage>>::Element *T = (*E.value).front(); T; T = T->next()) {
|
||||
for (const KeyValue<StringName, Usage> &U : T->get()) {
|
||||
for (const KeyValue<ShaderWarning::Code, HashMap<StringName, HashMap<StringName, Usage>> *> &E : warnings_check_map2) {
|
||||
for (const KeyValue<StringName, HashMap<StringName, Usage>> &T : *E.value) {
|
||||
for (const KeyValue<StringName, Usage> &U : T.value) {
|
||||
if (!U.value.used) {
|
||||
_add_warning(E.key, U.value.decl_line, U.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const KeyValue<ShaderWarning::Code, Map<StringName, Usage> *> &E : warnings_check_map) {
|
||||
for (const Map<StringName, Usage>::Element *U = (*E.value).front(); U; U = U->next()) {
|
||||
if (!U->get().used) {
|
||||
_add_warning(E.key, U->get().decl_line, U->key());
|
||||
for (const KeyValue<ShaderWarning::Code, HashMap<StringName, Usage> *> &E : warnings_check_map) {
|
||||
for (const KeyValue<StringName, Usage> &U : (*E.value)) {
|
||||
if (!U.value.used) {
|
||||
_add_warning(E.key, U.value.decl_line, U.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9546,7 +9546,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
|
|||
case COMPLETION_IDENTIFIER:
|
||||
case COMPLETION_FUNCTION_CALL: {
|
||||
bool comp_ident = completion_type == COMPLETION_IDENTIFIER;
|
||||
Map<String, ScriptLanguage::CodeCompletionKind> matches;
|
||||
HashMap<String, ScriptLanguage::CodeCompletionKind> matches;
|
||||
StringName skip_function;
|
||||
BlockNode *block = completion_block;
|
||||
|
||||
|
|
@ -9793,7 +9793,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
|
|||
}
|
||||
|
||||
int idx2 = 0;
|
||||
Set<int> out_args;
|
||||
RBSet<int> out_args;
|
||||
while (builtin_func_out_args[idx2].name != nullptr) {
|
||||
if (builtin_func_out_args[idx2].name == builtin_func_defs[idx].name) {
|
||||
for (int i = 0; i < BuiltinFuncOutArgs::MAX_ARGS; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue