summaryrefslogtreecommitdiff
path: root/modules/enet
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2021-07-17 18:22:52 -0300
committerreduz <reduzio@gmail.com>2021-07-18 21:20:02 -0300
commit6631f66c2a9d54dc80d57df60376c84ce1252d08 (patch)
tree9b68d49611f1b732e4f3901ff12e3b678d45adbd /modules/enet
parentb76dfde329592ecfd6f6b952082ae21859039e67 (diff)
Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor.
Diffstat (limited to 'modules/enet')
-rw-r--r--modules/enet/enet_multiplayer_peer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp
index a9726426ad..b4ca93f4d9 100644
--- a/modules/enet/enet_multiplayer_peer.cpp
+++ b/modules/enet/enet_multiplayer_peer.cpp
@@ -249,7 +249,7 @@ void ENetMultiplayerPeer::poll() {
connection_status = CONNECTION_CONNECTED; // If connecting, this means it connected to something!
- emit_signal("peer_connected", *new_id);
+ emit_signal(SNAME("peer_connected"), *new_id);
if (server) {
// Do not notify other peers when server_relay is disabled.
@@ -274,7 +274,7 @@ void ENetMultiplayerPeer::poll() {
enet_peer_send(E->get(), SYSCH_CONFIG, packet);
}
} else {
- emit_signal("connection_succeeded");
+ emit_signal(SNAME("connection_succeeded"));
}
} break;
@@ -285,7 +285,7 @@ void ENetMultiplayerPeer::poll() {
if (!id) {
if (!server) {
- emit_signal("connection_failed");
+ emit_signal(SNAME("connection_failed"));
}
// Never fully connected.
break;
@@ -293,7 +293,7 @@ void ENetMultiplayerPeer::poll() {
if (!server) {
// Client just disconnected from server.
- emit_signal("server_disconnected");
+ emit_signal(SNAME("server_disconnected"));
close_connection();
return;
} else if (server_relay) {
@@ -310,7 +310,7 @@ void ENetMultiplayerPeer::poll() {
}
}
- emit_signal("peer_disconnected", *id);
+ emit_signal(SNAME("peer_disconnected"), *id);
peer_map.erase(*id);
memdelete(id);
} break;
@@ -328,12 +328,12 @@ void ENetMultiplayerPeer::poll() {
switch (msg) {
case SYSMSG_ADD_PEER: {
peer_map[id] = nullptr;
- emit_signal("peer_connected", id);
+ emit_signal(SNAME("peer_connected"), id);
} break;
case SYSMSG_REMOVE_PEER: {
peer_map.erase(id);
- emit_signal("peer_disconnected", id);
+ emit_signal(SNAME("peer_disconnected"), id);
} break;
}
@@ -491,7 +491,7 @@ void ENetMultiplayerPeer::disconnect_peer(int p_peer, bool now) {
memdelete(id);
}
- emit_signal("peer_disconnected", p_peer);
+ emit_signal(SNAME("peer_disconnected"), p_peer);
peer_map.erase(p_peer);
} else {
enet_peer_disconnect_later(peer_map[p_peer], 0);