1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-18 14:21:41 +00:00

Optimize String.left() and String.right()

This commit is contained in:
MewPurPur
2023-08-20 20:01:06 +03:00
parent 0511f9d9a7
commit c9287e5224

View File

@@ -3665,7 +3665,9 @@ String String::left(int p_len) const {
return *this; return *this;
} }
return substr(0, p_len); String s;
s.copy_from_unchecked(&get_data()[0], p_len);
return s;
} }
String String::right(int p_len) const { String String::right(int p_len) const {
@@ -3681,7 +3683,9 @@ String String::right(int p_len) const {
return *this; return *this;
} }
return substr(length() - p_len); String s;
s.copy_from_unchecked(&get_data()[length() - p_len], p_len);
return s;
} }
char32_t String::unicode_at(int p_idx) const { char32_t String::unicode_at(int p_idx) const {