summaryrefslogtreecommitdiff
path: root/core/debugger
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2022-05-13 15:04:37 +0200
committerRĂ©mi Verschelde <rverschelde@gmail.com>2022-05-16 10:37:48 +0200
commit746dddc0673d7261f19b1e056e90e6e3a49ef33a (patch)
tree434b526eb286850ebccc6d2c998a7d90fdb8b5e2 /core/debugger
parent396def9b66c476f7834604adb7136ca903ed01be (diff)
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!
Diffstat (limited to 'core/debugger')
-rw-r--r--core/debugger/engine_debugger.cpp6
-rw-r--r--core/debugger/engine_debugger.h8
-rw-r--r--core/debugger/local_debugger.cpp4
-rw-r--r--core/debugger/local_debugger.h2
-rw-r--r--core/debugger/script_debugger.cpp2
-rw-r--r--core/debugger/script_debugger.h8
6 files changed, 15 insertions, 15 deletions
diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp
index 54760d8d65..263c75760b 100644
--- a/core/debugger/engine_debugger.cpp
+++ b/core/debugger/engine_debugger.cpp
@@ -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);
diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h
index fdfa41c9cc..a8a791f9b0 100644
--- a/core/debugger/engine_debugger.h
+++ b/core/debugger/engine_debugger.h
@@ -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"
@@ -96,9 +96,9 @@ protected:
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; }
diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp
index 4ed4c97c64..f378ba94c3 100644
--- a/core/debugger/local_debugger.cpp
+++ b/core/debugger/local_debugger.cpp
@@ -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));
}
diff --git a/core/debugger/local_debugger.h b/core/debugger/local_debugger.h
index ecd805a6cb..c687214c65 100644
--- a/core/debugger/local_debugger.h
+++ b/core/debugger/local_debugger.h
@@ -42,7 +42,7 @@ private:
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);
diff --git a/core/debugger/script_debugger.cpp b/core/debugger/script_debugger.cpp
index 4dd93249ef..1efa7f7690 100644
--- a/core/debugger/script_debugger.cpp
+++ b/core/debugger/script_debugger.cpp
@@ -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);
}
diff --git a/core/debugger/script_debugger.h b/core/debugger/script_debugger.h
index feb6702b54..a5a72d7c54 100644
--- a/core/debugger/script_debugger.h
+++ b/core/debugger/script_debugger.h
@@ -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 {
@@ -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;
@@ -66,7 +66,7 @@ public:
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;