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.
This commit is contained in:
reduz
2021-07-17 18:22:52 -03:00
parent b76dfde329
commit 6631f66c2a
236 changed files with 3694 additions and 3670 deletions

View File

@ -941,7 +941,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, uint16_t p_rpc_id, const
void MultiplayerAPI::_add_peer(int p_id) {
connected_peers.insert(p_id);
path_get_cache.insert(p_id, PathGetCache());
emit_signal("network_peer_connected", p_id);
emit_signal(SNAME("network_peer_connected"), p_id);
}
void MultiplayerAPI::_del_peer(int p_id) {
@ -956,19 +956,19 @@ void MultiplayerAPI::_del_peer(int p_id) {
PathSentCache *psc = path_send_cache.getptr(E->get());
psc->confirmed_peers.erase(p_id);
}
emit_signal("network_peer_disconnected", p_id);
emit_signal(SNAME("network_peer_disconnected"), p_id);
}
void MultiplayerAPI::_connected_to_server() {
emit_signal("connected_to_server");
emit_signal(SNAME("connected_to_server"));
}
void MultiplayerAPI::_connection_failed() {
emit_signal("connection_failed");
emit_signal(SNAME("connection_failed"));
}
void MultiplayerAPI::_server_disconnected() {
emit_signal("server_disconnected");
emit_signal(SNAME("server_disconnected"));
}
void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) {
@ -1059,7 +1059,7 @@ void MultiplayerAPI::_process_raw(int p_from, const uint8_t *p_packet, int p_pac
uint8_t *w = out.ptrw();
memcpy(&w[0], &p_packet[1], len);
}
emit_signal("network_peer_packet", p_from, out);
emit_signal(SNAME("network_peer_packet"), p_from, out);
}
int MultiplayerAPI::get_network_unique_id() const {