diff options
| author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-09-05 19:39:58 +0200 |
|---|---|---|
| committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-09-05 19:48:46 +0200 |
| commit | 9a94fe7d26bfc53569317897d73d1daf0e62130f (patch) | |
| tree | 06d75f2d6a9bdc45b38e73c39bb747856890ef04 /editor/editor_network_profiler.cpp | |
| parent | 4ee8ecd3efee742be58c1ff191e78d0de09b57b6 (diff) | |
| download | redot-engine-9a94fe7d26bfc53569317897d73d1daf0e62130f.tar.gz | |
Improve the `String::humanize_size()` method
- Use "B" insted of "Bytes" to be more compact
- Use suffixes that denote a binary prefix
- Make suffixes localizable
This removes the need for the custom
`EditorNetworkProfiler:_format_bandwidth()` method.
Diffstat (limited to 'editor/editor_network_profiler.cpp')
| -rw-r--r-- | editor/editor_network_profiler.cpp | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/editor/editor_network_profiler.cpp b/editor/editor_network_profiler.cpp index 5666448887..b90fe96cee 100644 --- a/editor/editor_network_profiler.cpp +++ b/editor/editor_network_profiler.cpp @@ -92,22 +92,6 @@ void EditorNetworkProfiler::_clear_pressed() { } } -String EditorNetworkProfiler::_format_bandwidth(int p_value) { - String unit = "B"; - float v = p_value; - if (v > 1073741824.0) { - unit = "GiB"; - v /= 1073741824.0; - } else if (v > 1048576.0) { - unit = "MiB"; - v /= 1048576.0; - } else if (v > 1024.0) { - unit = "KiB"; - v /= 1024.0; - } - return vformat("%.1f %s/s", v, unit); -} - void EditorNetworkProfiler::add_node_frame_data(const MultiplayerAPI::ProfilingInfo p_frame) { if (!nodes_data.has(p_frame.node)) { @@ -127,8 +111,8 @@ void EditorNetworkProfiler::add_node_frame_data(const MultiplayerAPI::ProfilingI void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) { - incoming_bandwidth_text->set_text(_format_bandwidth(p_incoming)); - outgoing_bandwidth_text->set_text(_format_bandwidth(p_outgoing)); + incoming_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_incoming))); + outgoing_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_outgoing))); } bool EditorNetworkProfiler::is_profiling() { |
