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!
This commit is contained in:
@ -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);
|
||||
|
||||
@ -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; }
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user