summaryrefslogtreecommitdiff
path: root/modules/webrtc
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/webrtc
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/webrtc')
-rw-r--r--modules/webrtc/webrtc_multiplayer_peer.cpp12
-rw-r--r--modules/webrtc/webrtc_peer_connection_js.cpp6
2 files changed, 9 insertions, 9 deletions
diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp
index ac75f9e860..51101e3124 100644
--- a/modules/webrtc/webrtc_multiplayer_peer.cpp
+++ b/modules/webrtc/webrtc_multiplayer_peer.cpp
@@ -123,19 +123,19 @@ void WebRTCMultiplayerPeer::poll() {
// Already connected to server: simply notify new peer.
// NOTE: Mesh is always connected.
if (connection_status == CONNECTION_CONNECTED) {
- emit_signal("peer_connected", E->get());
+ emit_signal(SNAME("peer_connected"), E->get());
}
// Server emulation mode suppresses peer_conencted until server connects.
if (server_compat && E->get() == TARGET_PEER_SERVER) {
// Server connected.
connection_status = CONNECTION_CONNECTED;
- emit_signal("peer_connected", TARGET_PEER_SERVER);
- emit_signal("connection_succeeded");
+ emit_signal(SNAME("peer_connected"), TARGET_PEER_SERVER);
+ emit_signal(SNAME("connection_succeeded"));
// Notify of all previously connected peers
for (Map<int, Ref<ConnectedPeer>>::Element *F = peer_map.front(); F; F = F->next()) {
if (F->key() != 1 && F->get()->connected) {
- emit_signal("peer_connected", F->key());
+ emit_signal(SNAME("peer_connected"), F->key());
}
}
break; // Because we already notified of all newly added peers.
@@ -283,9 +283,9 @@ void WebRTCMultiplayerPeer::remove_peer(int p_peer_id) {
peer_map.erase(p_peer_id);
if (peer->connected) {
peer->connected = false;
- emit_signal("peer_disconnected", p_peer_id);
+ emit_signal(SNAME("peer_disconnected"), p_peer_id);
if (server_compat && p_peer_id == TARGET_PEER_SERVER) {
- emit_signal("server_disconnected");
+ emit_signal(SNAME("server_disconnected"));
connection_status = CONNECTION_DISCONNECTED;
}
}
diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp
index 2b63e76358..ed3459d5f8 100644
--- a/modules/webrtc/webrtc_peer_connection_js.cpp
+++ b/modules/webrtc/webrtc_peer_connection_js.cpp
@@ -38,12 +38,12 @@
void WebRTCPeerConnectionJS::_on_ice_candidate(void *p_obj, const char *p_mid_name, int p_mline_idx, const char *p_candidate) {
WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj);
- peer->emit_signal("ice_candidate_created", String(p_mid_name), p_mline_idx, String(p_candidate));
+ peer->emit_signal(SNAME("ice_candidate_created"), String(p_mid_name), p_mline_idx, String(p_candidate));
}
void WebRTCPeerConnectionJS::_on_session_created(void *p_obj, const char *p_type, const char *p_session) {
WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj);
- peer->emit_signal("session_description_created", String(p_type), String(p_session));
+ peer->emit_signal(SNAME("session_description_created"), String(p_type), String(p_session));
}
void WebRTCPeerConnectionJS::_on_connection_state_changed(void *p_obj, int p_state) {
@@ -57,7 +57,7 @@ void WebRTCPeerConnectionJS::_on_error(void *p_obj) {
void WebRTCPeerConnectionJS::_on_data_channel(void *p_obj, int p_id) {
WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj);
- peer->emit_signal("data_channel_received", Ref<WebRTCDataChannelJS>(new WebRTCDataChannelJS(p_id)));
+ peer->emit_signal(SNAME("data_channel_received"), Ref<WebRTCDataChannelJS>(new WebRTCDataChannelJS(p_id)));
}
void WebRTCPeerConnectionJS::close() {