mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Add a new HashSet template
* Intended to replace RBSet in most cases. * Optimized for iteration speed
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
#ifndef GDSCRIPT_TRANSLATION_PARSER_PLUGIN_H
|
||||
#define GDSCRIPT_TRANSLATION_PARSER_PLUGIN_H
|
||||
|
||||
#include "core/templates/rb_set.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "editor/editor_translation_parser.h"
|
||||
#include "modules/gdscript/gdscript_parser.h"
|
||||
|
||||
@@ -44,9 +44,9 @@ class GDScriptEditorTranslationParserPlugin : public EditorTranslationParserPlug
|
||||
// List of patterns used for extracting translation strings.
|
||||
StringName tr_func = "tr";
|
||||
StringName trn_func = "tr_n";
|
||||
RBSet<StringName> assignment_patterns;
|
||||
RBSet<StringName> first_arg_patterns;
|
||||
RBSet<StringName> second_arg_patterns;
|
||||
HashSet<StringName> assignment_patterns;
|
||||
HashSet<StringName> first_arg_patterns;
|
||||
HashSet<StringName> second_arg_patterns;
|
||||
// FileDialog patterns.
|
||||
StringName fd_add_filter = "add_filter";
|
||||
StringName fd_set_filter = "set_filters";
|
||||
|
||||
@@ -788,7 +788,7 @@ void GDScript::update_exports() {
|
||||
return;
|
||||
}
|
||||
|
||||
RBSet<ObjectID> copy = inheriters_cache; //might get modified
|
||||
HashSet<ObjectID> copy = inheriters_cache; //might get modified
|
||||
|
||||
for (const ObjectID &E : copy) {
|
||||
Object *id = ObjectDB::get_instance(E);
|
||||
@@ -937,7 +937,7 @@ void GDScript::get_constants(HashMap<StringName, Variant> *p_constants) {
|
||||
}
|
||||
}
|
||||
|
||||
void GDScript::get_members(RBSet<StringName> *p_members) {
|
||||
void GDScript::get_members(HashSet<StringName> *p_members) {
|
||||
if (p_members) {
|
||||
for (const StringName &E : members) {
|
||||
p_members->insert(E);
|
||||
@@ -1916,7 +1916,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
while (script->placeholders.size()) {
|
||||
Object *obj = script->placeholders.front()->get()->get_owner();
|
||||
Object *obj = (*script->placeholders.begin())->get_owner();
|
||||
|
||||
//save instance info
|
||||
if (obj->get_script_instance()) {
|
||||
@@ -1926,7 +1926,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
|
||||
obj->set_script(Variant());
|
||||
} else {
|
||||
// no instance found. Let's remove it so we don't loop forever
|
||||
script->placeholders.erase(script->placeholders.front()->get());
|
||||
script->placeholders.erase(*script->placeholders.begin());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/io/resource_saver.h"
|
||||
#include "core/object/script_language.h"
|
||||
#include "core/templates/rb_set.h"
|
||||
#include "gdscript_function.h"
|
||||
|
||||
class GDScriptNativeClass : public RefCounted {
|
||||
@@ -80,7 +81,7 @@ class GDScript : public Script {
|
||||
GDScript *_base = nullptr; //fast pointer access
|
||||
GDScript *_owner = nullptr; //for subclasses
|
||||
|
||||
RBSet<StringName> members; //members are just indices to the instantiated script.
|
||||
HashSet<StringName> members; //members are just indices to the instantiated script.
|
||||
HashMap<StringName, Variant> constants;
|
||||
HashMap<StringName, GDScriptFunction *> member_functions;
|
||||
HashMap<StringName, MemberInfo> member_indices; //members are just indices to the instantiated script.
|
||||
@@ -95,7 +96,7 @@ class GDScript : public Script {
|
||||
List<PropertyInfo> members_cache;
|
||||
HashMap<StringName, Variant> member_default_values_cache;
|
||||
Ref<GDScript> base_cache;
|
||||
RBSet<ObjectID> inheriters_cache;
|
||||
HashSet<ObjectID> inheriters_cache;
|
||||
bool source_changed_cache = false;
|
||||
bool placeholder_fallback_enabled = false;
|
||||
void _update_exports_values(HashMap<StringName, Variant> &values, List<PropertyInfo> &propnames);
|
||||
@@ -139,7 +140,7 @@ class GDScript : public Script {
|
||||
String _get_debug_path() const;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
RBSet<PlaceHolderScriptInstance *> placeholders;
|
||||
HashSet<PlaceHolderScriptInstance *> placeholders;
|
||||
//void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
|
||||
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override;
|
||||
#endif
|
||||
@@ -178,7 +179,7 @@ public:
|
||||
|
||||
const HashMap<StringName, Ref<GDScript>> &get_subclasses() const { return subclasses; }
|
||||
const HashMap<StringName, Variant> &get_constants() const { return constants; }
|
||||
const RBSet<StringName> &get_members() const { return members; }
|
||||
const HashSet<StringName> &get_members() const { return members; }
|
||||
const GDScriptDataType &get_member_type(const StringName &p_member) const {
|
||||
CRASH_COND(!member_indices.has(p_member));
|
||||
return member_indices[p_member].data_type;
|
||||
@@ -246,7 +247,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void get_constants(HashMap<StringName, Variant> *p_constants) override;
|
||||
virtual void get_members(RBSet<StringName> *p_members) override;
|
||||
virtual void get_members(HashSet<StringName> *p_members) override;
|
||||
|
||||
virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override;
|
||||
|
||||
@@ -449,7 +450,7 @@ public:
|
||||
virtual bool is_using_templates() override;
|
||||
virtual Ref<Script> make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const override;
|
||||
virtual Vector<ScriptTemplate> get_built_in_templates(StringName p_object) override;
|
||||
virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::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<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, HashSet<int> *r_safe_lines = nullptr) const override;
|
||||
virtual Script *create_script() const override;
|
||||
virtual bool has_named_classes() const override;
|
||||
virtual bool supports_builtin_mode() const override;
|
||||
|
||||
@@ -898,7 +898,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class) {
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
RBSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
|
||||
HashSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
|
||||
for (uint32_t ignored_warning : member.function->ignored_warnings) {
|
||||
parser->ignored_warning_codes.insert(ignored_warning);
|
||||
}
|
||||
@@ -947,7 +947,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class) {
|
||||
GDScriptParser::ClassNode::Member member = p_class->members[i];
|
||||
if (member.type == GDScriptParser::ClassNode::Member::VARIABLE) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
RBSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
|
||||
HashSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
|
||||
for (uint32_t ignored_warning : member.function->ignored_warnings) {
|
||||
parser->ignored_warning_codes.insert(ignored_warning);
|
||||
}
|
||||
@@ -1279,7 +1279,7 @@ void GDScriptAnalyzer::resolve_suite(GDScriptParser::SuiteNode *p_suite) {
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
RBSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
|
||||
HashSet<uint32_t> previously_ignored = parser->ignored_warning_codes;
|
||||
for (uint32_t ignored_warning : stmt->ignored_warnings) {
|
||||
parser->ignored_warning_codes.insert(ignored_warning);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "core/object/object.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/templates/rb_set.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "gdscript_cache.h"
|
||||
#include "gdscript_parser.h"
|
||||
|
||||
|
||||
@@ -223,13 +223,13 @@ Error GDScriptCache::finish_compiling(const String &p_owner) {
|
||||
singleton->full_gdscript_cache[p_owner] = script.ptr();
|
||||
singleton->shallow_gdscript_cache.erase(p_owner);
|
||||
|
||||
RBSet<String> depends = singleton->dependencies[p_owner];
|
||||
HashSet<String> depends = singleton->dependencies[p_owner];
|
||||
|
||||
Error err = OK;
|
||||
for (const RBSet<String>::Element *E = depends.front(); E != nullptr; E = E->next()) {
|
||||
for (const String &E : depends) {
|
||||
Error this_err = OK;
|
||||
// No need to save the script. We assume it's already referenced in the owner.
|
||||
get_full_script(E->get(), this_err);
|
||||
get_full_script(E, this_err);
|
||||
|
||||
if (this_err != OK) {
|
||||
err = this_err;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/os/mutex.h"
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/rb_set.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "gdscript.h"
|
||||
|
||||
class GDScriptAnalyzer;
|
||||
@@ -74,7 +74,7 @@ class GDScriptCache {
|
||||
HashMap<String, GDScriptParserRef *> parser_map;
|
||||
HashMap<String, GDScript *> shallow_gdscript_cache;
|
||||
HashMap<String, GDScript *> full_gdscript_cache;
|
||||
HashMap<String, RBSet<String>> dependencies;
|
||||
HashMap<String, HashSet<String>> dependencies;
|
||||
|
||||
friend class GDScript;
|
||||
friend class GDScriptParserRef;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#ifndef GDSCRIPT_COMPILER_H
|
||||
#define GDSCRIPT_COMPILER_H
|
||||
|
||||
#include "core/templates/rb_set.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "gdscript.h"
|
||||
#include "gdscript_codegen.h"
|
||||
#include "gdscript_function.h"
|
||||
@@ -39,8 +39,8 @@
|
||||
|
||||
class GDScriptCompiler {
|
||||
const GDScriptParser *parser = nullptr;
|
||||
RBSet<GDScript *> parsed_classes;
|
||||
RBSet<GDScript *> parsing_classes;
|
||||
HashSet<GDScript *> parsed_classes;
|
||||
HashSet<GDScript *> parsing_classes;
|
||||
GDScript *main_script = nullptr;
|
||||
|
||||
struct CodeGen {
|
||||
|
||||
@@ -110,7 +110,7 @@ static void get_function_names_recursively(const GDScriptParser::ClassNode *p_cl
|
||||
}
|
||||
}
|
||||
|
||||
bool GDScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, RBSet<int> *r_safe_lines) const {
|
||||
bool GDScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, HashSet<int> *r_safe_lines) const {
|
||||
GDScriptParser parser;
|
||||
GDScriptAnalyzer analyzer(&parser);
|
||||
|
||||
@@ -159,7 +159,7 @@ bool GDScriptLanguage::validate(const String &p_script, const String &p_path, Li
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (r_safe_lines) {
|
||||
const RBSet<int> &unsafe_lines = parser.get_unsafe_lines();
|
||||
const HashSet<int> &unsafe_lines = parser.get_unsafe_lines();
|
||||
for (int i = 1; i <= parser.get_last_line_number(); i++) {
|
||||
if (!unsafe_lines.has(i)) {
|
||||
r_safe_lines->insert(i);
|
||||
|
||||
@@ -1205,9 +1205,9 @@ private:
|
||||
List<ParserError> errors;
|
||||
#ifdef DEBUG_ENABLED
|
||||
List<GDScriptWarning> warnings;
|
||||
RBSet<String> ignored_warnings;
|
||||
RBSet<uint32_t> ignored_warning_codes;
|
||||
RBSet<int> unsafe_lines;
|
||||
HashSet<String> ignored_warnings;
|
||||
HashSet<uint32_t> ignored_warning_codes;
|
||||
HashSet<int> unsafe_lines;
|
||||
#endif
|
||||
|
||||
GDScriptTokenizer tokenizer;
|
||||
@@ -1419,7 +1419,7 @@ public:
|
||||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
const List<GDScriptWarning> &get_warnings() const { return warnings; }
|
||||
const RBSet<int> &get_unsafe_lines() const { return unsafe_lines; }
|
||||
const HashSet<int> &get_unsafe_lines() const { return unsafe_lines; }
|
||||
int get_last_line_number() const { return current.end_line; }
|
||||
#endif
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#define GDSCRIPT_TOKENIZER_H
|
||||
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "core/templates/list.h"
|
||||
#include "core/templates/rb_set.h"
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/variant/variant.h"
|
||||
|
||||
|
||||
@@ -784,7 +784,7 @@ GDScriptWorkspace::GDScriptWorkspace() {
|
||||
}
|
||||
|
||||
GDScriptWorkspace::~GDScriptWorkspace() {
|
||||
RBSet<String> cached_parsers;
|
||||
HashSet<String> cached_parsers;
|
||||
|
||||
for (const KeyValue<String, ExtendGDScriptParser *> &E : parse_results) {
|
||||
cached_parsers.insert(E.key);
|
||||
|
||||
@@ -70,7 +70,7 @@ class EditorExportGDScript : public EditorExportPlugin {
|
||||
GDCLASS(EditorExportGDScript, EditorExportPlugin);
|
||||
|
||||
public:
|
||||
virtual void _export_file(const String &p_path, const String &p_type, const RBSet<String> &p_features) override {
|
||||
virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override {
|
||||
int script_mode = EditorExportPreset::MODE_SCRIPT_COMPILED;
|
||||
String script_key;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user