Optimized path_clean_end_slash in String.

This commit is contained in:
Relintai 2023-12-22 19:26:41 +01:00
parent 978e49a289
commit 57c3233187

View File

@ -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;