1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #104286 from Ivorforce/localvector-find

Harmonize `String`, `Vector` and `LocalVector` `find` and `rfind`.
This commit is contained in:
Rémi Verschelde
2025-03-19 12:27:27 +01:00
4 changed files with 42 additions and 26 deletions

View File

@@ -3347,6 +3347,12 @@ int String::find(const char *p_str, int p_from) const {
}
int String::find_char(char32_t p_char, int p_from) const {
if (p_from < 0) {
p_from = length() + p_from;
}
if (p_from < 0 || p_from >= length()) {
return -1;
}
return span().find(p_char, p_from);
}
@@ -3584,6 +3590,12 @@ int String::rfind(const char *p_str, int p_from) const {
}
int String::rfind_char(char32_t p_char, int p_from) const {
if (p_from < 0) {
p_from = length() + p_from;
}
if (p_from < 0 || p_from >= length()) {
return -1;
}
return span().rfind(p_char, p_from);
}