Skip to content

Commit

Permalink
Use HashMap
Browse files Browse the repository at this point in the history
OrderedHashMap -> HashMap
Map -> HashMap

See godot commit 8b7c7f5a753b43cec10f72b274bb1d70c253652b
godotengine/godot#60999
  • Loading branch information
Meptl committed May 9, 2023
1 parent 64fc9b5 commit 82b163c
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 29 deletions.
14 changes: 7 additions & 7 deletions core/command_line_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ String CommandLineParser::_get_usage(const Vector<Pair<const CommandLineOption *
return usage;
}

String CommandLineParser::_get_options_description(const OrderedHashMap<String, PackedStringArray> &p_categories_data) const {
String CommandLineParser::_get_options_description(const HashMap<String, PackedStringArray> &p_categories_data) const {
String description;
for (OrderedHashMap<String, PackedStringArray>::ConstElement E = p_categories_data.front(); E; E = E.next()) {
for (HashMap<String, PackedStringArray>::ConstElement E = p_categories_data.front(); E; E = E.next()) {
const String &category = E.key();
const PackedStringArray &lines = E.value();

Expand Down Expand Up @@ -685,7 +685,7 @@ Error CommandLineParser::parse(const PackedStringArray &p_args) {
}
for (int i = 0; i < _options.size(); ++i) {
CommandLineOption *option = _options.get(i).ptr();
const Map<const CommandLineOption *, PackedStringArray>::Element *E = _parsed_values.find(option);
HashMap<const CommandLineOption *, PackedStringArray>::Element *E = _parsed_values.find(option);
if (E) {
option->emit_signal("parsed", E->value());
}
Expand Down Expand Up @@ -801,7 +801,7 @@ String CommandLineParser::get_value(const Ref<CommandLineOption> &p_option) cons
PackedStringArray CommandLineParser::get_value_list(const Ref<CommandLineOption> &p_option) const {
ERR_FAIL_COND_V(p_option.is_null(), PackedStringArray());
ERR_FAIL_COND_V_MSG(p_option->get_arg_count() == 0, PackedStringArray(), vformat("Option '%s' does not accept arguments.", _to_string(p_option->get_names())));
const Map<const CommandLineOption *, PackedStringArray>::Element *E = _parsed_values.find(p_option.ptr());
HashMap<const CommandLineOption *, PackedStringArray>::Element *E = _parsed_values.find(p_option.ptr());
if (!E) {
return PackedStringArray();
}
Expand All @@ -819,7 +819,7 @@ String CommandLineParser::get_prefix(const Ref<CommandLineOption> &p_option) con

PackedStringArray CommandLineParser::get_prefix_list(const Ref<CommandLineOption> &p_option) const {
ERR_FAIL_COND_V(p_option.is_null(), PackedStringArray());
const Map<const CommandLineOption *, PackedStringArray>::Element *E = _parsed_prefixes.find(p_option.ptr());
HashMap<const CommandLineOption *, PackedStringArray>::Element *E = _parsed_prefixes.find(p_option.ptr());
if (!E) {
return PackedStringArray();
}
Expand All @@ -828,7 +828,7 @@ PackedStringArray CommandLineParser::get_prefix_list(const Ref<CommandLineOption

int CommandLineParser::get_occurrence_count(const Ref<CommandLineOption> &p_option) const {
ERR_FAIL_COND_V(p_option.is_null(), 0);
const Map<const CommandLineOption *, int>::Element *E = _parsed_count.find(p_option.ptr());
HashMap<const CommandLineOption *, int>::Element *E = _parsed_count.find(p_option.ptr());
if (!E) {
return 0;
}
Expand Down Expand Up @@ -866,7 +866,7 @@ String CommandLineParser::get_help_text(const Ref<CommandLineHelpFormat> &p_form
const int descriptions_length = format->get_line_length() - options_length;

// Fill categories and their data.
OrderedHashMap<String, PackedStringArray> categories_data;
HashMap<String, PackedStringArray> categories_data;
for (int i = 0; i < printable_options.size(); ++i) {
String line = printable_options[i].second.rpad(options_length - format->get_left_pad());
line = line.lpad(line.length() + format->get_left_pad());
Expand Down
8 changes: 4 additions & 4 deletions core/command_line_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class CommandLineParser : public RefCounted {
PackedStringArray _long_prefixes;
PackedStringArray _short_prefixes;

Map<const CommandLineOption *, PackedStringArray> _parsed_values;
Map<const CommandLineOption *, PackedStringArray> _parsed_prefixes;
Map<const CommandLineOption *, int> _parsed_count;
HashMap<const CommandLineOption *, PackedStringArray> _parsed_values;
HashMap<const CommandLineOption *, PackedStringArray> _parsed_prefixes;
HashMap<const CommandLineOption *, int> _parsed_count;

String _error_text;

Expand Down Expand Up @@ -173,7 +173,7 @@ class CommandLineParser : public RefCounted {

// Help text printers.
String _get_usage(const Vector<Pair<const CommandLineOption *, String>> &p_printable_options, const String &p_title) const;
String _get_options_description(const OrderedHashMap<String, PackedStringArray> &p_categories_data) const;
String _get_options_description(const HashMap<String, PackedStringArray> &p_categories_data) const;

// Other utilies.
String _to_string(const PackedStringArray &p_names) const; // Returns all option names separated by commas with all prefix variants.
Expand Down
2 changes: 1 addition & 1 deletion core/goost_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Dictionary GoostEngine::get_color_constants() const {
_populate_named_colors(); // color_names.inc
}
Dictionary colors;
for (Map<String, Color>::Element *E = _named_colors.front(); E; E = E->next()) {
for (HashMap<String, Color>::Element *E = _named_colors.front(); E; E = E->next()) {
colors[E->key()] = E->get();
}
return colors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void PolyBoolean2DClipper10::boolean_polypaths_tree(const Vector<Vector<Point2>>
clp.Execute(clip_type, tree, solution_open, subject_fill_rule);

List<clipperlib::PolyPath *> to_visit;
Map<clipperlib::PolyPath *, PolyNode2D *> nodes;
HashMap<clipperlib::PolyPath *, PolyNode2D *> nodes;

nodes.insert(&tree, r_root);
to_visit.push_back(&tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void PolyBoolean2DClipper6::boolean_polypaths_tree(const Vector<Vector<Point2>>
clp.Execute(clip_type, tree, subject_fill_type, clip_fill_type);

List<ClipperLib::PolyNode *> to_visit;
Map<ClipperLib::PolyNode *, PolyNode2D *> nodes;
HashMap<ClipperLib::PolyNode *, PolyNode2D *> nodes;

nodes.insert(&tree, r_root);
to_visit.push_back(&tree);
Expand Down
2 changes: 1 addition & 1 deletion core/script/mixin_script/mixin_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void MixinScript::set_mixin(int p_idx, const Ref<Script> &p_script) {
mixins.set(p_idx, p_script);
Ref<Script> s = p_script;

for (Map<Object *, MixinScriptInstance *>::Element *E = instances.front(); E; E = E->next()) {
for (HashMap<Object *, MixinScriptInstance *>::Element *E = instances.front(); E; E = E->next()) {
MixinScriptInstance *msi = E->get();
// Looks like there's no need to explicitly free a previous
// script instance in `msi->instances`, because `s->instance_create`
Expand Down
2 changes: 1 addition & 1 deletion core/script/mixin_script/mixin_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MixinScript : public Script {

Vector<Ref<Script> > mixins;
Vector<Mixin *> mixin_instances;
Map<Object *, MixinScriptInstance *> instances;
HashMap<Object *, MixinScriptInstance *> instances;

protected:
static void _bind_methods();
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript_transpiler/gdscript_transpiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GDScriptTranspiler {

class GDScriptTranspilerLanguage {
protected:
Map<String, GDScriptTranspilerUtils::CodeBuilder> code;
HashMap<String, GDScriptTranspilerUtils::CodeBuilder> code;
String script_path;

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Variant GDScriptTranspilerCpp::transpile(const Ref<GDScript> &p_script) {
transpile_node(cpp_tree);

Dictionary ret;
for (Map<String, GDScriptTranspilerUtils::CodeBuilder>::Element *E = code.front(); E; E = E->next()) {
for (HashMap<String, GDScriptTranspilerUtils::CodeBuilder>::Element *E = code.front(); E; E = E->next()) {
ret[E->key()] = E->get().get_code();
}
clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class GDScriptTranspilerCpp : public GDScriptTranspilerLanguage {
}
};
Vector<Member> variables;
Map<StringName, Constant> constant_expressions;
HashMap<StringName, Constant> constant_expressions;
Vector<FunctionNode *> functions;

ClassNode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ String ResourceImporterAnimatedTexture::get_save_extension() const {
return "atex";
}

bool ResourceImporterAnimatedTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
bool ResourceImporterAnimatedTexture::get_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ResourceImporterAnimatedTexture : public ResourceImporter {
virtual String get_preset_name(int p_idx) const;

virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
virtual bool get_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const;

virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr);
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr);
};

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ String ResourceImporterSpriteFrames::get_save_extension() const {
return "sframes";
}

bool ResourceImporterSpriteFrames::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
bool ResourceImporterSpriteFrames::get_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/gif/editor/import/resource_importer_sprite_frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ResourceImporterSpriteFrames : public ResourceImporter {
virtual String get_preset_name(int p_idx) const;

virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
virtual bool get_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const;

virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr);
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr);
};

2 changes: 1 addition & 1 deletion modules/git/git_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Array EditorVCSInterfaceGit::_get_modified_files_data() {
} else {
path = entry->head_to_index->new_file.path;
}
static Map<int, ChangeType> map_changes;
static HashMap<int, ChangeType> map_changes;
map_changes[GIT_STATUS_WT_NEW] = CHANGE_TYPE_NEW;
map_changes[GIT_STATUS_INDEX_NEW] = CHANGE_TYPE_NEW;
map_changes[GIT_STATUS_WT_MODIFIED] = CHANGE_TYPE_MODIFIED;
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/poly_generators_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class PolyRectangle2D : public PolyNode2D {
class PolyPath2D : public PolyNode2D {
GDCLASS(PolyPath2D, PolyNode2D);

Map<ObjectID, Ref<Curve2D>> paths; // Path2D : Cached Curve2D
HashMap<ObjectID, Ref<Curve2D>> paths; // Path2D : Cached Curve2D

real_t buffer_offset = 32.0;
Ref<PolyOffsetParameters2D> buffer_parameters;
Expand All @@ -125,7 +125,7 @@ class PolyPath2D : public PolyNode2D {

void set_tessellation_stages(int p_tessellation_stages);
int get_tessellation_stages() const { return tessellation_stages; }

void set_tessellation_tolerance_degrees(float p_tessellation_tolerance_degrees);
float get_tessellation_tolerance_degrees() const { return tessellation_tolerance_degrees; }

Expand Down
2 changes: 1 addition & 1 deletion scene/gui/grid_rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GridRect : public Control {
void _update_colors();

private:
Map<Vector2i, Variant> metadata;
HashMap<Vector2i, Variant> metadata;
Dictionary current_line;

Vector2 _point_snapped;
Expand Down

0 comments on commit 82b163c

Please sign in to comment.