diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-06-08 21:57:55 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-06-08 22:05:57 +0200 |
commit | 746bfc366244373b8d385b3761e14cb2c9eaa1fc (patch) | |
tree | be967cadbaa0f6a150d78b32fdaa18382efba605 | |
parent | abbbde87e28982150d30e748b89c5303384909ca (diff) | |
download | redot-engine-746bfc366244373b8d385b3761e14cb2c9eaa1fc.tar.gz |
Fix display of large sizes in the editor monitors
Unlike the old custom method, the `String::humanize_size()`
method works well with file sizes above 2 GB.
This also tweaks the suffixes for spacing consistency and
uses the correct acronym for exabytes (EB).
This closes #29610.
-rw-r--r-- | core/ustring.cpp | 2 | ||||
-rw-r--r-- | editor/script_editor_debugger.cpp | 16 |
2 files changed, 3 insertions, 15 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 88b758e883..f62e1b381b 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3235,7 +3235,7 @@ static int _humanize_digits(int p_num) { String String::humanize_size(size_t p_size) { uint64_t _div = 1; - static const char *prefix[] = { " Bytes", " KB", " MB", " GB", "TB", " PB", "HB", "" }; + static const char *prefix[] = { " Bytes", " KB", " MB", " GB", " TB", " PB", " EB", "" }; int prefix_idx = 0; while (p_size > (_div * 1024) && prefix[prefix_idx][0]) { diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index c3b62810f1..3b086c6316 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -727,20 +727,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String tt = vs; switch (Performance::MonitorType((int)perf_items[i]->get_metadata(1))) { case Performance::MONITOR_TYPE_MEMORY: { - // for the time being, going above GBs is a bad sign. - String unit = "B"; - if ((int)v > 1073741824) { - unit = "GB"; - v /= 1073741824.0; - } else if ((int)v > 1048576) { - unit = "MB"; - v /= 1048576.0; - } else if ((int)v > 1024) { - unit = "KB"; - v /= 1024.0; - } - tt += " bytes"; - vs = String::num(v, 2) + " " + unit; + vs = String::humanize_size(v); + tt = vs; } break; case Performance::MONITOR_TYPE_TIME: { tt += " seconds"; |