Use (r)find_char instead of (r)find for single characters

This commit is contained in:
A Thousand Ships
2024-11-16 18:52:15 +01:00
parent 5efd124ca1
commit 68f638cf02
70 changed files with 169 additions and 169 deletions

View File

@ -407,7 +407,7 @@ NodePath::NodePath(const String &p_path) {
bool absolute = (path[0] == '/');
bool last_is_slash = true;
int slices = 0;
int subpath_pos = path.find(":");
int subpath_pos = path.find_char(':');
if (subpath_pos != -1) {
int from = subpath_pos + 1;

View File

@ -227,11 +227,11 @@ void TranslationPO::set_plural_rule(const String &p_plural_rule) {
// Set plural_forms and plural_rule.
// p_plural_rule passed in has the form "Plural-Forms: nplurals=2; plural=(n >= 2);".
int first_semi_col = p_plural_rule.find(";");
plural_forms = p_plural_rule.substr(p_plural_rule.find("=") + 1, first_semi_col - (p_plural_rule.find("=") + 1)).to_int();
int first_semi_col = p_plural_rule.find_char(';');
plural_forms = p_plural_rule.substr(p_plural_rule.find_char('=') + 1, first_semi_col - (p_plural_rule.find_char('=') + 1)).to_int();
int expression_start = p_plural_rule.find("=", first_semi_col) + 1;
int second_semi_col = p_plural_rule.rfind(";");
int expression_start = p_plural_rule.find_char('=', first_semi_col) + 1;
int second_semi_col = p_plural_rule.rfind_char(';');
plural_rule = p_plural_rule.substr(expression_start, second_semi_col - expression_start).strip_edges();
// Setup the cache to make evaluating plural rule faster later on.

View File

@ -246,27 +246,27 @@ Error String::parse_url(String &r_scheme, String &r_host, int &r_port, String &r
base = base.substr(pos + 3, base.length() - pos - 3);
}
}
pos = base.find("#");
pos = base.find_char('#');
// Fragment
if (pos != -1) {
r_fragment = base.substr(pos + 1);
base = base.substr(0, pos);
}
pos = base.find("/");
pos = base.find_char('/');
// Path
if (pos != -1) {
r_path = base.substr(pos, base.length() - pos);
base = base.substr(0, pos);
}
// Host
pos = base.find("@");
pos = base.find_char('@');
if (pos != -1) {
// Strip credentials
base = base.substr(pos + 1, base.length() - pos - 1);
}
if (base.begins_with("[")) {
// Literal IPv6
pos = base.rfind("]");
pos = base.rfind_char(']');
if (pos == -1) {
return ERR_INVALID_PARAMETER;
}
@ -277,7 +277,7 @@ Error String::parse_url(String &r_scheme, String &r_host, int &r_port, String &r
if (base.get_slice_count(":") > 2) {
return ERR_INVALID_PARAMETER;
}
pos = base.rfind(":");
pos = base.rfind_char(':');
if (pos == -1) {
r_host = base;
base = "";
@ -2641,7 +2641,7 @@ int64_t String::to_int() const {
return 0;
}
int to = (find(".") >= 0) ? find(".") : length();
int to = (find_char('.') >= 0) ? find_char('.') : length();
int64_t integer = 0;
int64_t sign = 1;
@ -4580,7 +4580,7 @@ String String::simplify_path() const {
if (p == -1) {
p = s.find(":\\");
}
if (p != -1 && p < s.find("/")) {
if (p != -1 && p < s.find_char('/')) {
drive = s.substr(0, p + 2);
s = s.substr(p + 2);
}
@ -5025,7 +5025,7 @@ String String::xml_unescape() const {
String String::pad_decimals(int p_digits) const {
String s = *this;
int c = s.find(".");
int c = s.find_char('.');
if (c == -1) {
if (p_digits <= 0) {
@ -5049,7 +5049,7 @@ String String::pad_decimals(int p_digits) const {
String String::pad_zeros(int p_digits) const {
String s = *this;
int end = s.find(".");
int end = s.find_char('.');
if (end == -1) {
end = s.length();
@ -5316,7 +5316,7 @@ String String::validate_filename() const {
}
bool String::is_valid_ip_address() const {
if (find(":") >= 0) {
if (find_char(':') >= 0) {
Vector<String> ip = split(":");
for (int i = 0; i < ip.size(); i++) {
const String &n = ip[i];
@ -5386,13 +5386,13 @@ String String::get_base_dir() const {
// Windows UNC network share path.
if (end == 0) {
if (is_network_share_path()) {
basepos = find("/", 2);
basepos = find_char('/', 2);
if (basepos == -1) {
basepos = find("\\", 2);
basepos = find_char('\\', 2);
}
int servpos = find("/", basepos + 1);
int servpos = find_char('/', basepos + 1);
if (servpos == -1) {
servpos = find("\\", basepos + 1);
servpos = find_char('\\', basepos + 1);
}
if (servpos != -1) {
end = servpos + 1;
@ -5416,7 +5416,7 @@ String String::get_base_dir() const {
rs = *this;
}
int sep = MAX(rs.rfind("/"), rs.rfind("\\"));
int sep = MAX(rs.rfind_char('/'), rs.rfind_char('\\'));
if (sep == -1) {
return base;
}
@ -5425,7 +5425,7 @@ String String::get_base_dir() const {
}
String String::get_file() const {
int sep = MAX(rfind("/"), rfind("\\"));
int sep = MAX(rfind_char('/'), rfind_char('\\'));
if (sep == -1) {
return *this;
}
@ -5434,8 +5434,8 @@ String String::get_file() const {
}
String String::get_extension() const {
int pos = rfind(".");
if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) {
int pos = rfind_char('.');
if (pos < 0 || pos < MAX(rfind_char('/'), rfind_char('\\'))) {
return "";
}
@ -5533,8 +5533,8 @@ String String::validate_node_name() const {
}
String String::get_basename() const {
int pos = rfind(".");
if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) {
int pos = rfind_char('.');
if (pos < 0 || pos < MAX(rfind_char('/'), rfind_char('\\'))) {
return *this;
}