summaryrefslogtreecommitdiff
path: root/core/object
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2022-05-19 17:00:06 +0200
committerreduz <reduzio@gmail.com>2022-05-20 22:40:38 +0200
commit45af29da8095af16729955117a165d23e77cd740 (patch)
tree0436c59187702466a73d05caf9688a58e5935afd /core/object
parent410893ad0fb6f0d7d774b6529581d886defd6cf0 (diff)
Add a new HashSet template
* Intended to replace RBSet in most cases. * Optimized for iteration speed
Diffstat (limited to 'core/object')
-rw-r--r--core/object/class_db.cpp2
-rw-r--r--core/object/class_db.h5
-rw-r--r--core/object/object.h6
-rw-r--r--core/object/script_language.cpp2
-rw-r--r--core/object/script_language.h4
-rw-r--r--core/object/script_language_extension.h4
6 files changed, 12 insertions, 11 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index d19cbf2642..f61bd24efd 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<String> *p
}
HashMap<StringName, HashMap<StringName, Variant>> ClassDB::default_values;
-RBSet<StringName> ClassDB::default_values_cached;
+HashSet<StringName> 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)) {
diff --git a/core/object/class_db.h b/core/object/class_db.h
index 67b71ab058..2448a86e33 100644
--- a/core/object/class_db.h
+++ b/core/object/class_db.h
@@ -38,6 +38,7 @@
// Makes callable_mp readily available in all classes connecting signals.
// Needs to come after method_bind and object have been included.
#include "core/object/callable_method_pointer.h"
+#include "core/templates/hash_set.h"
#define DEFVAL(m_defval) (m_defval)
@@ -110,7 +111,7 @@ public:
#ifdef DEBUG_METHODS_ENABLED
List<StringName> constant_order;
List<StringName> method_order;
- RBSet<StringName> methods_in_properties;
+ HashSet<StringName> methods_in_properties;
List<MethodInfo> virtual_methods;
HashMap<StringName, MethodInfo> virtual_methods_map;
HashMap<StringName, Vector<Error>> method_error_values;
@@ -149,7 +150,7 @@ public:
static void _add_class2(const StringName &p_class, const StringName &p_inherits);
static HashMap<StringName, HashMap<StringName, Variant>> default_values;
- static RBSet<StringName> default_values_cached;
+ static HashSet<StringName> default_values_cached;
// Native structs, used by binder
struct NativeStruct {
diff --git a/core/object/object.h b/core/object/object.h
index ca7b9965f1..988d261d77 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -37,9 +37,9 @@
#include "core/os/rw_lock.h"
#include "core/os/spin_lock.h"
#include "core/templates/hash_map.h"
+#include "core/templates/hash_set.h"
#include "core/templates/list.h"
#include "core/templates/rb_map.h"
-#include "core/templates/rb_set.h"
#include "core/templates/safe_refcount.h"
#include "core/templates/vmap.h"
#include "core/variant/callable_bind.h"
@@ -510,7 +510,7 @@ private:
#ifdef TOOLS_ENABLED
bool _edited = false;
uint32_t _edited_version = 0;
- RBSet<String> editor_section_folding;
+ HashSet<String> editor_section_folding;
#endif
ScriptInstance *script_instance = nullptr;
Variant script; // Reference does not exist yet, store it in a Variant.
@@ -815,7 +815,7 @@ public:
#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 RBSet<String> &editor_get_section_folding() const { return editor_section_folding; }
+ const HashSet<String> &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 1546d52fd2..66c9a80193 100644
--- a/core/object/script_language.cpp
+++ b/core/object/script_language.cpp
@@ -475,7 +475,7 @@ bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const {
}
void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, const HashMap<StringName, Variant> &p_values) {
- RBSet<StringName> new_values;
+ HashSet<StringName> new_values;
for (const PropertyInfo &E : p_properties) {
StringName n = E.name;
new_values.insert(n);
diff --git a/core/object/script_language.h b/core/object/script_language.h
index b1481a372e..0a8e79a24e 100644
--- a/core/object/script_language.h
+++ b/core/object/script_language.h
@@ -155,7 +155,7 @@ public:
virtual int get_member_line(const StringName &p_member) const { return -1; }
virtual void get_constants(HashMap<StringName, Variant> *p_constants) {}
- virtual void get_members(RBSet<StringName> *p_constants) {}
+ virtual void get_members(HashSet<StringName> *p_constants) {}
virtual bool is_placeholder_fallback_enabled() const { return false; }
@@ -283,7 +283,7 @@ public:
virtual Ref<Script> make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const { return Ref<Script>(); }
virtual Vector<ScriptTemplate> get_built_in_templates(StringName p_object) { return Vector<ScriptTemplate>(); }
virtual bool is_using_templates() { return false; }
- virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptError> *r_errors = nullptr, List<Warning> *r_warnings = nullptr, RBSet<int> *r_safe_lines = nullptr) const = 0;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptError> *r_errors = nullptr, List<Warning> *r_warnings = nullptr, HashSet<int> *r_safe_lines = nullptr) const = 0;
virtual String validate_path(const String &p_path) const { return ""; }
virtual Script *create_script() const = 0;
virtual bool has_named_classes() const = 0;
diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h
index 5ffa6c5a70..406a431a11 100644
--- a/core/object/script_language_extension.h
+++ b/core/object/script_language_extension.h
@@ -163,7 +163,7 @@ public:
}
}
GDVIRTUAL0RC(TypedArray<StringName>, _get_members)
- virtual void get_members(RBSet<StringName> *p_members) override {
+ virtual void get_members(HashSet<StringName> *p_members) override {
TypedArray<StringName> members;
GDVIRTUAL_REQUIRED_CALL(_get_members, members);
for (int i = 0; i < members.size(); i++) {
@@ -282,7 +282,7 @@ public:
EXBIND0R(bool, is_using_templates)
GDVIRTUAL6RC(Dictionary, _validate, const String &, const String &, bool, bool, bool, bool)
- virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptError> *r_errors = nullptr, List<Warning> *r_warnings = nullptr, RBSet<int> *r_safe_lines = nullptr) const override {
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptError> *r_errors = nullptr, List<Warning> *r_warnings = nullptr, HashSet<int> *r_safe_lines = nullptr) const override {
Dictionary ret;
GDVIRTUAL_REQUIRED_CALL(_validate, p_script, p_path, r_functions != nullptr, r_errors != nullptr, r_warnings != nullptr, r_safe_lines != nullptr, ret);
if (!ret.has("valid")) {