mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-26 05:37:13 +01:00
Optimized path_clean_end_slash in String.
This commit is contained in:
parent
978e49a289
commit
57c3233187
@ -4205,8 +4205,17 @@ String String::path_clean_end_slash() const {
|
|||||||
|
|
||||||
String ret = *this;
|
String ret = *this;
|
||||||
|
|
||||||
while (ret.length() > 1 && (ret.ends_with("/") || ret.ends_with("\\"))) {
|
int strip_to = ret.length() - 1;
|
||||||
ret.resize(ret.length());
|
|
||||||
|
CharType c = ret[strip_to];
|
||||||
|
|
||||||
|
while (strip_to > 1 && (c == '/' || c == '\\')) {
|
||||||
|
--strip_to;
|
||||||
|
c = ret[strip_to];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.length() != strip_to + 1) {
|
||||||
|
ret.set_length(strip_to + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user