diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-07-08 18:23:53 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-07-08 18:23:53 +0200 |
commit | 83cc5d4914a6bff76069ac19191192337e4df3de (patch) | |
tree | 37cd045b49e43970287dc4c5a5790388864a12fb /core/string/ustring.cpp | |
parent | 8eeb7c90610205a26cd7f28c67e619eaf9c190d0 (diff) | |
parent | cc5500f7de954e461c843237346527220bbce0ba (diff) | |
download | redot-engine-83cc5d4914a6bff76069ac19191192337e4df3de.tar.gz |
Merge pull request #79202 from MewPurPur/fix-pad-zeros-error
Fix erroneous `pad_zeros()` warning
Diffstat (limited to 'core/string/ustring.cpp')
-rw-r--r-- | core/string/ustring.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 49c7ead423..12e6423724 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -4281,12 +4281,13 @@ String String::pad_zeros(int p_digits) const { begin++; } - if (begin >= end) { + int zeros_to_add = p_digits - (end - begin); + + if (zeros_to_add <= 0) { return s; + } else { + return s.insert(begin, String("0").repeat(zeros_to_add)); } - - int zeros_to_add = p_digits - (end - begin); - return s.insert(begin, String("0").repeat(zeros_to_add)); } String String::trim_prefix(const String &p_prefix) const { |