Skip to content

Commit

Permalink
Merge pull request #60999 from reduz/replace-rbhash-by-hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored May 16, 2022
2 parents 396def9 + 746dddc commit c1277c2
Show file tree
Hide file tree
Showing 587 changed files with 3,696 additions and 3,527 deletions.
4 changes: 2 additions & 2 deletions core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ void Engine::add_singleton(const Singleton &p_singleton) {
}

Object *Engine::get_singleton_object(const StringName &p_name) const {
const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
HashMap<StringName, Object *>::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 {
Expand Down
2 changes: 1 addition & 1 deletion core/config/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Engine {
bool _in_physics = false;

List<Singleton> singletons;
Map<StringName, Object *> singleton_ptrs;
HashMap<StringName, Object *> singleton_ptrs;

bool editor_hint = false;
bool project_manager_hint = false;
Expand Down
51 changes: 26 additions & 25 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ struct _VCSort {
void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const {
_THREAD_SAFE_METHOD_

Set<_VCSort> vclist;
RBSet<_VCSort> vclist;

for (const KeyValue<StringName, VariantContainer> &E : props) {
const VariantContainer *v = &E.value;
Expand Down Expand Up @@ -360,7 +360,7 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *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)) {
Expand Down Expand Up @@ -764,7 +764,7 @@ Error ProjectSettings::save() {
return error;
}

Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<String, List<String>> &props, const CustomMap &p_custom, const String &p_custom_features) {
Error ProjectSettings::_save_settings_binary(const String &p_file, const HashMap<String, List<String>> &props, const CustomMap &p_custom, const String &p_custom_features) {
Error err;
Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
ERR_FAIL_COND_V_MSG(err != OK, err, "Couldn't save project.binary at " + p_file + ".");
Expand Down Expand Up @@ -800,19 +800,20 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str
file->store_32(count); //store how many properties are saved
}

for (Map<String, List<String>>::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<String, List<String>> &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);
Expand All @@ -831,7 +832,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str
return OK;
}

Error ProjectSettings::_save_settings_text(const String &p_file, const Map<String, List<String>> &props, const CustomMap &p_custom, const String &p_custom_features) {
Error ProjectSettings::_save_settings_text(const String &p_file, const HashMap<String, List<String>> &props, const CustomMap &p_custom, const String &p_custom_features) {
Error err;
Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);

Expand All @@ -852,18 +853,18 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
}
file->store_string("\n");

for (const Map<String, List<String>>::Element *E = props.front(); E; E = E->next()) {
if (E != props.front()) {
for (const KeyValue<String, List<String>> &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)) {
Expand Down Expand Up @@ -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<StringName, VariantContainer> &G : props) {
Expand Down Expand Up @@ -946,19 +947,19 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust

for (const KeyValue<String, Variant> &E : p_custom) {
// Lookup global prop to store in the same order
Map<StringName, VariantContainer>::Element *global_prop = props.find(E.key);
HashMap<StringName, VariantContainer>::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<String, List<String>> props;
HashMap<String, List<String>> 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;

Expand Down Expand Up @@ -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<StringName, PropertyInfo> &ProjectSettings::get_custom_property_info() const {
const HashMap<StringName, PropertyInfo> &ProjectSettings::get_custom_property_info() const {
return custom_prop_info;
}

Expand Down
18 changes: 9 additions & 9 deletions core/config/project_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Variant> CustomMap;
typedef HashMap<String, Variant> CustomMap;
static const String PROJECT_DATA_DIR_NAME_SUFFIX;

enum {
Expand Down Expand Up @@ -84,15 +84,15 @@ class ProjectSettings : public Object {
int last_builtin_order = 0;
uint64_t last_save_time = 0;

Map<StringName, VariantContainer> props;
HashMap<StringName, VariantContainer> props;
String resource_path;
Map<StringName, PropertyInfo> custom_prop_info;
HashMap<StringName, PropertyInfo> custom_prop_info;
bool disable_feature_overrides = false;
bool using_datapack = false;
List<String> input_presets;

Set<String> custom_features;
Map<StringName, StringName> feature_overrides;
RBSet<String> custom_features;
HashMap<StringName, StringName> feature_overrides;

HashMap<StringName, AutoloadInfo> autoloads;

Expand All @@ -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<String, List<String>> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
Error _save_settings_binary(const String &p_file, const Map<String, List<String>> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
Error _save_settings_text(const String &p_file, const HashMap<String, List<String>> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
Error _save_settings_binary(const String &p_file, const HashMap<String, List<String>> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());

Error _save_custom_bnd(const String &p_file);

Expand Down Expand Up @@ -168,7 +168,7 @@ class ProjectSettings : public Object {
Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true);
Error save();
void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info);
const Map<StringName, PropertyInfo> &get_custom_property_info() const;
const HashMap<StringName, PropertyInfo> &get_custom_property_info() const;
uint64_t get_last_saved_time() { return last_save_time; }

Vector<String> get_optimizer_presets() const;
Expand Down
2 changes: 1 addition & 1 deletion core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void OS::print_resources_by_type(const Vector<String> &p_types) {

print_line(vformat("Resources currently in use for the following types: %s", p_types));

Map<String, int> type_count;
RBMap<String, int> type_count;
List<Ref<Resource>> resources;
ResourceCache::get_cached_resources(&resources);

Expand Down
4 changes: 2 additions & 2 deletions core/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ class Engine : public Object {
class EngineDebugger : public Object {
GDCLASS(EngineDebugger, Object);

Map<StringName, Callable> captures;
Map<StringName, Ref<EngineProfiler>> profilers;
HashMap<StringName, Callable> captures;
HashMap<StringName, Ref<EngineProfiler>> profilers;

protected:
static void _bind_methods();
Expand Down
6 changes: 3 additions & 3 deletions core/debugger/engine_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
EngineDebugger *EngineDebugger::singleton = nullptr;
ScriptDebugger *EngineDebugger::script_debugger = nullptr;

Map<StringName, EngineDebugger::Profiler> EngineDebugger::profilers;
Map<StringName, EngineDebugger::Capture> EngineDebugger::captures;
Map<String, EngineDebugger::CreatePeerFunc> EngineDebugger::protocols;
HashMap<StringName, EngineDebugger::Profiler> EngineDebugger::profilers;
HashMap<StringName, EngineDebugger::Capture> EngineDebugger::captures;
HashMap<String, EngineDebugger::CreatePeerFunc> 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);
Expand Down
8 changes: 4 additions & 4 deletions core/debugger/engine_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -96,9 +96,9 @@ class EngineDebugger {
static EngineDebugger *singleton;
static ScriptDebugger *script_debugger;

static Map<StringName, Profiler> profilers;
static Map<StringName, Capture> captures;
static Map<String, CreatePeerFunc> protocols;
static HashMap<StringName, Profiler> profilers;
static HashMap<StringName, Capture> captures;
static HashMap<String, CreatePeerFunc> protocols;

public:
_FORCE_INLINE_ static EngineDebugger *get_singleton() { return singleton; }
Expand Down
4 changes: 2 additions & 2 deletions core/debugger/local_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, Set<StringName>> &breakpoints = script_debugger->get_breakpoints();
const HashMap<int, RBSet<StringName>> &breakpoints = script_debugger->get_breakpoints();
if (breakpoints.size() == 0) {
print_line("No Breakpoints.");
continue;
}

print_line("Breakpoint(s): " + itos(breakpoints.size()));
for (const KeyValue<int, Set<StringName>> &E : breakpoints) {
for (const KeyValue<int, RBSet<StringName>> &E : breakpoints) {
print_line("\t" + String(E.value.front()->get()) + ":" + itos(E.key));
}

Expand Down
2 changes: 1 addition & 1 deletion core/debugger/local_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LocalDebugger : public EngineDebugger {
ScriptsProfiler *scripts_profiler = nullptr;

String target_function;
Map<String, String> options;
HashMap<String, String> options;

Pair<String, int> to_breakpoint(const String &p_line);
void print_variables(const List<String> &names, const List<Variant> &values, const String &variable_prefix);
Expand Down
2 changes: 1 addition & 1 deletion core/debugger/script_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<StringName>();
breakpoints[p_line] = RBSet<StringName>();
}
breakpoints[p_line].insert(p_source);
}
Expand Down
8 changes: 4 additions & 4 deletions core/debugger/script_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -44,7 +44,7 @@ class ScriptDebugger {
int depth = -1;
bool skip_breakpoints = false;

Map<int, Set<StringName>> breakpoints;
HashMap<int, RBSet<StringName>> breakpoints;

ScriptLanguage *break_lang = nullptr;
Vector<StackInfo> error_stack_info;
Expand All @@ -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<int, Set<StringName>> &get_breakpoints() const { return breakpoints; }
const HashMap<int, RBSet<StringName>> &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;
Expand Down
4 changes: 2 additions & 2 deletions core/doc_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -161,7 +161,7 @@ class DocData {
Vector<MethodDoc> operators;
Vector<MethodDoc> signals;
Vector<ConstantDoc> constants;
Map<String, String> enums;
HashMap<String, String> enums;
Vector<PropertyDoc> properties;
Vector<ThemeItemDoc> theme_properties;
bool is_script_doc = false;
Expand Down
2 changes: 1 addition & 1 deletion core/extension/extension_api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
{
// Global enums and constants.
Array constants;
Map<String, List<Pair<String, int>>> enum_list;
HashMap<String, List<Pair<String, int>>> enum_list;

for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
int value = CoreConstants::get_global_constant_value(i);
Expand Down
2 changes: 1 addition & 1 deletion core/extension/native_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class NativeExtension : public Resource {
ObjectNativeExtension native_extension;
};

Map<StringName, Extension> extension_classes;
HashMap<StringName, Extension> 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);
Expand Down
4 changes: 2 additions & 2 deletions core/extension/native_extension_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ Vector<String> NativeExtensionManager::get_loaded_extensions() const {
return ret;
}
Ref<NativeExtension> NativeExtensionManager::get_extension(const String &p_path) {
Map<String, Ref<NativeExtension>>::Element *E = native_extension_map.find(p_path);
HashMap<String, Ref<NativeExtension>>::Iterator E = native_extension_map.find(p_path);
ERR_FAIL_COND_V(!E, Ref<NativeExtension>());
return E->get();
return E->value;
}

void NativeExtensionManager::initialize_extensions(NativeExtension::InitializationLevel p_level) {
Expand Down
2 changes: 1 addition & 1 deletion core/extension/native_extension_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NativeExtensionManager : public Object {
GDCLASS(NativeExtensionManager, Object);

int32_t level = -1;
Map<String, Ref<NativeExtension>> native_extension_map;
HashMap<String, Ref<NativeExtension>> native_extension_map;

static void _bind_methods();

Expand Down
Loading

0 comments on commit c1277c2

Please sign in to comment.