diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-06-12 10:45:58 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-06-12 16:34:44 +0800 |
commit | 6f38c21253acf759230ea2e3300cb84df672fbcd (patch) | |
tree | 6b3b89114dead596ccf853ce17f082321cae23b8 /core/string | |
parent | d4235f51b1a88e48d676b877422fb121d326935c (diff) |
Fix parameter name for String.left and String.right
Diffstat (limited to 'core/string')
-rw-r--r-- | core/string/ustring.cpp | 24 | ||||
-rw-r--r-- | core/string/ustring.h | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index d189f3224b..df1aae5370 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3359,36 +3359,36 @@ String String::repeat(int p_count) const { return new_string; } -String String::left(int p_pos) const { - if (p_pos < 0) { - p_pos = length() + p_pos; +String String::left(int p_len) const { + if (p_len < 0) { + p_len = length() + p_len; } - if (p_pos <= 0) { + if (p_len <= 0) { return ""; } - if (p_pos >= length()) { + if (p_len >= length()) { return *this; } - return substr(0, p_pos); + return substr(0, p_len); } -String String::right(int p_pos) const { - if (p_pos < 0) { - p_pos = length() + p_pos; +String String::right(int p_len) const { + if (p_len < 0) { + p_len = length() + p_len; } - if (p_pos <= 0) { + if (p_len <= 0) { return ""; } - if (p_pos >= length()) { + if (p_len >= length()) { return *this; } - return substr(length() - p_pos); + return substr(length() - p_len); } char32_t String::unicode_at(int p_idx) const { diff --git a/core/string/ustring.h b/core/string/ustring.h index e4f6c3327a..11d0974381 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -356,8 +356,8 @@ public: int count(const String &p_string, int p_from = 0, int p_to = 0) const; int countn(const String &p_string, int p_from = 0, int p_to = 0) const; - String left(int p_pos) const; - String right(int p_pos) const; + String left(int p_len) const; + String right(int p_len) const; String indent(const String &p_prefix) const; String dedent() const; String strip_edges(bool left = true, bool right = true) const; |