1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Use initializer list in Arrays

This commit is contained in:
kobewi
2024-03-22 22:53:26 +01:00
parent 594d64ec24
commit 75881f8322
72 changed files with 347 additions and 947 deletions

View File

@@ -150,9 +150,7 @@ void MultiplayerDebugger::BandwidthProfiler::tick(double p_frame_time, double p_
int incoming_bandwidth = bandwidth_usage(bandwidth_in, bandwidth_in_ptr);
int outgoing_bandwidth = bandwidth_usage(bandwidth_out, bandwidth_out_ptr);
Array arr;
arr.push_back(incoming_bandwidth);
arr.push_back(outgoing_bandwidth);
Array arr = { incoming_bandwidth, outgoing_bandwidth };
EngineDebugger::get_singleton()->send_message("multiplayer:bandwidth", arr);
}
}
@@ -160,8 +158,7 @@ void MultiplayerDebugger::BandwidthProfiler::tick(double p_frame_time, double p_
// RPCProfiler
Array MultiplayerDebugger::RPCFrame::serialize() {
Array arr;
arr.push_back(infos.size() * 6);
Array arr = { infos.size() * 6 };
for (int i = 0; i < infos.size(); ++i) {
arr.push_back(uint64_t(infos[i].node));
arr.push_back(infos[i].node_path);
@@ -270,8 +267,7 @@ bool MultiplayerDebugger::SyncInfo::read_from_array(const Array &p_arr, int p_of
}
Array MultiplayerDebugger::ReplicationFrame::serialize() {
Array arr;
arr.push_back(infos.size() * 7);
Array arr = { infos.size() * 7 };
for (const KeyValue<ObjectID, SyncInfo> &E : infos) {
E.value.write_to_array(arr);
}

View File

@@ -40,10 +40,11 @@
#ifdef DEBUG_ENABLED
_FORCE_INLINE_ void SceneMultiplayer::_profile_bandwidth(const String &p_what, int p_value) {
if (EngineDebugger::is_profiling("multiplayer:bandwidth")) {
Array values;
values.push_back(p_what);
values.push_back(OS::get_singleton()->get_ticks_msec());
values.push_back(p_value);
Array values = {
p_what,
OS::get_singleton()->get_ticks_msec(),
p_value
};
EngineDebugger::profiler_add_frame_data("multiplayer:bandwidth", values);
}
}

View File

@@ -43,10 +43,7 @@
#ifdef DEBUG_ENABLED
_FORCE_INLINE_ void SceneReplicationInterface::_profile_node_data(const String &p_what, ObjectID p_id, int p_size) {
if (EngineDebugger::is_profiling("multiplayer:replication")) {
Array values;
values.push_back(p_what);
values.push_back(p_id);
values.push_back(p_size);
Array values = { p_what, p_id, p_size };
EngineDebugger::profiler_add_frame_data("multiplayer:replication", values);
}
}

View File

@@ -54,10 +54,7 @@
#ifdef DEBUG_ENABLED
_FORCE_INLINE_ void SceneRPCInterface::_profile_node_data(const String &p_what, ObjectID p_id, int p_size) {
if (EngineDebugger::is_profiling("multiplayer:rpc")) {
Array values;
values.push_back(p_what);
values.push_back(p_id);
values.push_back(p_size);
Array values = { p_what, p_id, p_size };
EngineDebugger::profiler_add_frame_data("multiplayer:rpc", values);
}
}