summaryrefslogtreecommitdiff
path: root/platform/linuxbsd
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 /platform/linuxbsd
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 'platform/linuxbsd')
-rw-r--r--platform/linuxbsd/display_server_x11.cpp28
-rw-r--r--platform/linuxbsd/display_server_x11.h16
-rw-r--r--platform/linuxbsd/export/export_plugin.h2
-rw-r--r--platform/linuxbsd/tts_linux.h4
4 files changed, 25 insertions, 25 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index 9f53b31567..5829711698 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -2360,10 +2360,10 @@ void DisplayServerX11::cursor_set_custom_image(const Ref<Resource> &p_cursor, Cu
_THREAD_SAFE_METHOD_
if (p_cursor.is_valid()) {
- Map<CursorShape, Vector<Variant>>::Element *cursor_c = cursors_cache.find(p_shape);
+ HashMap<CursorShape, Vector<Variant>>::Iterator cursor_c = cursors_cache.find(p_shape);
if (cursor_c) {
- if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ if (cursor_c->value[0] == p_cursor && cursor_c->value[1] == p_hotspot) {
cursor_set_shape(p_shape);
return;
}
@@ -3456,9 +3456,9 @@ void DisplayServerX11::process_events() {
}
if (XIMaskIsSet(raw_event->valuators.mask, VALUATOR_PRESSURE)) {
- Map<int, Vector2>::Element *pen_pressure = xi.pen_pressure_range.find(device_id);
+ HashMap<int, Vector2>::Iterator pen_pressure = xi.pen_pressure_range.find(device_id);
if (pen_pressure) {
- Vector2 pen_pressure_range = pen_pressure->value();
+ Vector2 pen_pressure_range = pen_pressure->value;
if (pen_pressure_range != Vector2()) {
xi.pressure_supported = true;
xi.pressure = (*values - pen_pressure_range[0]) /
@@ -3470,9 +3470,9 @@ void DisplayServerX11::process_events() {
}
if (XIMaskIsSet(raw_event->valuators.mask, VALUATOR_TILTX)) {
- Map<int, Vector2>::Element *pen_tilt_x = xi.pen_tilt_x_range.find(device_id);
+ HashMap<int, Vector2>::Iterator pen_tilt_x = xi.pen_tilt_x_range.find(device_id);
if (pen_tilt_x) {
- Vector2 pen_tilt_x_range = pen_tilt_x->value();
+ Vector2 pen_tilt_x_range = pen_tilt_x->value;
if (pen_tilt_x_range[0] != 0 && *values < 0) {
xi.tilt.x = *values / -pen_tilt_x_range[0];
} else if (pen_tilt_x_range[1] != 0) {
@@ -3484,9 +3484,9 @@ void DisplayServerX11::process_events() {
}
if (XIMaskIsSet(raw_event->valuators.mask, VALUATOR_TILTY)) {
- Map<int, Vector2>::Element *pen_tilt_y = xi.pen_tilt_y_range.find(device_id);
+ HashMap<int, Vector2>::Iterator pen_tilt_y = xi.pen_tilt_y_range.find(device_id);
if (pen_tilt_y) {
- Vector2 pen_tilt_y_range = pen_tilt_y->value();
+ Vector2 pen_tilt_y_range = pen_tilt_y->value;
if (pen_tilt_y_range[0] != 0 && *values < 0) {
xi.tilt.y = *values / -pen_tilt_y_range[0];
} else if (pen_tilt_y_range[1] != 0) {
@@ -3508,11 +3508,11 @@ void DisplayServerX11::process_events() {
xi.raw_pos.x = rel_x;
xi.raw_pos.y = rel_y;
- Map<int, Vector2>::Element *abs_info = xi.absolute_devices.find(device_id);
+ HashMap<int, Vector2>::Iterator abs_info = xi.absolute_devices.find(device_id);
if (abs_info) {
// Absolute mode device
- Vector2 mult = abs_info->value();
+ Vector2 mult = abs_info->value;
xi.relative_motion.x += (xi.raw_pos.x - xi.old_raw_pos.x) * mult.x;
xi.relative_motion.y += (xi.raw_pos.y - xi.old_raw_pos.y) * mult.y;
@@ -3557,21 +3557,21 @@ void DisplayServerX11::process_events() {
} break;
case XI_TouchUpdate: {
- Map<int, Vector2>::Element *curr_pos_elem = xi.state.find(index);
+ HashMap<int, Vector2>::Iterator curr_pos_elem = xi.state.find(index);
if (!curr_pos_elem) { // Defensive
break;
}
- if (curr_pos_elem->value() != pos) {
+ if (curr_pos_elem->value != pos) {
Ref<InputEventScreenDrag> sd;
sd.instantiate();
sd->set_window_id(window_id);
sd->set_index(index);
sd->set_position(pos);
- sd->set_relative(pos - curr_pos_elem->value());
+ sd->set_relative(pos - curr_pos_elem->value);
Input::get_singleton()->parse_input_event(sd);
- curr_pos_elem->value() = pos;
+ curr_pos_elem->value = pos;
}
} break;
#endif
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
index ee47d1a12c..66941fbe29 100644
--- a/platform/linuxbsd/display_server_x11.h
+++ b/platform/linuxbsd/display_server_x11.h
@@ -137,7 +137,7 @@ class DisplayServerX11 : public DisplayServer {
Callable drop_files_callback;
WindowID transient_parent = INVALID_WINDOW_ID;
- Set<WindowID> transient_children;
+ RBSet<WindowID> transient_children;
ObjectID instance_id;
@@ -159,7 +159,7 @@ class DisplayServerX11 : public DisplayServer {
unsigned int focus_order = 0;
};
- Map<WindowID, WindowData> windows;
+ HashMap<WindowID, WindowData> windows;
unsigned int last_mouse_monitor_mask = 0;
Vector2i last_mouse_monitor_pos;
@@ -197,12 +197,12 @@ class DisplayServerX11 : public DisplayServer {
struct {
int opcode;
Vector<int> touch_devices;
- Map<int, Vector2> absolute_devices;
- Map<int, Vector2> pen_pressure_range;
- Map<int, Vector2> pen_tilt_x_range;
- Map<int, Vector2> pen_tilt_y_range;
+ HashMap<int, Vector2> absolute_devices;
+ HashMap<int, Vector2> pen_pressure_range;
+ HashMap<int, Vector2> pen_tilt_x_range;
+ HashMap<int, Vector2> pen_tilt_y_range;
XIEventMask all_event_mask;
- Map<int, Vector2> state;
+ HashMap<int, Vector2> state;
double pressure;
bool pressure_supported;
Vector2 tilt;
@@ -241,7 +241,7 @@ class DisplayServerX11 : public DisplayServer {
Cursor cursors[CURSOR_MAX];
Cursor null_cursor;
CursorShape current_cursor = CURSOR_ARROW;
- Map<CursorShape, Vector<Variant>> cursors_cache;
+ HashMap<CursorShape, Vector<Variant>> cursors_cache;
bool layered_window = false;
diff --git a/platform/linuxbsd/export/export_plugin.h b/platform/linuxbsd/export/export_plugin.h
index f46fc68e1d..9ae5cf827a 100644
--- a/platform/linuxbsd/export/export_plugin.h
+++ b/platform/linuxbsd/export/export_plugin.h
@@ -38,7 +38,7 @@
#include "scene/resources/texture.h"
class EditorExportPlatformLinuxBSD : public EditorExportPlatformPC {
- Map<String, String> extensions;
+ HashMap<String, String> extensions;
Error _export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path);
public:
diff --git a/platform/linuxbsd/tts_linux.h b/platform/linuxbsd/tts_linux.h
index 4d39af8970..4e3f348ae4 100644
--- a/platform/linuxbsd/tts_linux.h
+++ b/platform/linuxbsd/tts_linux.h
@@ -35,7 +35,7 @@
#include "core/os/thread_safe.h"
#include "core/string/ustring.h"
#include "core/templates/list.h"
-#include "core/templates/map.h"
+#include "core/templates/rb_map.h"
#include "core/variant/array.h"
#include "servers/display_server.h"
@@ -49,7 +49,7 @@ class TTS_Linux {
bool speaking = false;
bool paused = false;
int last_msg_id = -1;
- Map<int, int> ids;
+ HashMap<int, int> ids;
Thread init_thread;