mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Repair String lstrip and rstrip.
Background: lstrip and rstrip were broken by changes to String in:
0e29f7974b
which removed it's access to Vector::find(CharType).
Moved Vector's find up into CowData so it can be shared by Vector and String.
Added String::find_char using CowData::find.
Implemented rstrip and lstrip using find_char.
Added a few tests for String rstrip and lstrip.
This commit is contained in:
parent
bcecf56267
commit
cbb396c006
5 changed files with 105 additions and 19 deletions
|
@ -2393,6 +2393,10 @@ int String::find(const char *p_str, int p_from) const {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int String::find_char(CharType p_char, int p_from) const {
|
||||
return _cowdata.find(p_char, p_from);
|
||||
}
|
||||
|
||||
int String::findmk(const Vector<String> &p_keys, int p_from, int *r_key) const {
|
||||
|
||||
if (p_from < 0)
|
||||
|
@ -3063,7 +3067,7 @@ String String::lstrip(const String &p_chars) const {
|
|||
|
||||
for (beg = 0; beg < len; beg++) {
|
||||
|
||||
if (p_chars.find(&ptr()[beg]) == -1)
|
||||
if (p_chars.find_char(get(beg)) == -1)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3080,7 +3084,7 @@ String String::rstrip(const String &p_chars) const {
|
|||
|
||||
for (end = len - 1; end >= 0; end--) {
|
||||
|
||||
if (p_chars.find(&ptr()[end]) == -1)
|
||||
if (p_chars.find_char(get(end)) == -1)
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue