Merge pull request #40092 from hinlopen/remove-find-last
Remove String::find_last (same as rfind)
This commit is contained in:
commit
c020eea184
26 changed files with 41 additions and 80 deletions
|
|
@ -169,7 +169,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Ve
|
|||
|
||||
for (int i = 0; i < p_breakpoints.size(); i++) {
|
||||
String bp = p_breakpoints[i];
|
||||
int sp = bp.find_last(":");
|
||||
int sp = bp.rfind(":");
|
||||
ERR_CONTINUE_MSG(sp == -1, "Invalid breakpoint: '" + bp + "', expected file:line format.");
|
||||
|
||||
singleton_script_debugger->insert_breakpoint(bp.substr(sp + 1, bp.length()).to_int(), bp.substr(0, sp));
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ RemoteDebuggerPeer *RemoteDebuggerPeerTCP::create(const String &p_uri) {
|
|||
uint16_t debug_port = 6007;
|
||||
|
||||
if (debug_host.find(":") != -1) {
|
||||
int sep_pos = debug_host.find_last(":");
|
||||
int sep_pos = debug_host.rfind(":");
|
||||
debug_port = debug_host.substr(sep_pos + 1).to_int();
|
||||
debug_host = debug_host.substr(0, sep_pos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -865,7 +865,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
|
|||
bool near_match = false;
|
||||
|
||||
for (int i = 0; i < res_remaps.size(); i++) {
|
||||
int split = res_remaps[i].find_last(":");
|
||||
int split = res_remaps[i].rfind(":");
|
||||
if (split == -1) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ String ProjectSettings::localize_path(const String &p_path) const {
|
|||
} else {
|
||||
memdelete(dir);
|
||||
|
||||
int sep = path.find_last("/");
|
||||
int sep = path.rfind("/");
|
||||
if (sep == -1) {
|
||||
return "res://" + path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2280,18 +2280,6 @@ String String::substr(int p_from, int p_chars) const {
|
|||
return s;
|
||||
}
|
||||
|
||||
int String::find_last(const String &p_str) const {
|
||||
int pos = -1;
|
||||
int findfrom = 0;
|
||||
int findres = -1;
|
||||
while ((findres = find(p_str, findfrom)) != -1) {
|
||||
pos = findres;
|
||||
findfrom = pos + 1;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
int String::find(const String &p_str, int p_from) const {
|
||||
if (p_from < 0) {
|
||||
return -1;
|
||||
|
|
@ -2582,7 +2570,7 @@ int String::rfindn(const String &p_str, int p_from) const {
|
|||
}
|
||||
|
||||
bool String::ends_with(const String &p_string) const {
|
||||
int pos = find_last(p_string);
|
||||
int pos = rfind(p_string);
|
||||
if (pos == -1) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3831,7 +3819,7 @@ String String::get_base_dir() const {
|
|||
}
|
||||
}
|
||||
|
||||
int sep = MAX(rs.find_last("/"), rs.find_last("\\"));
|
||||
int sep = MAX(rs.rfind("/"), rs.rfind("\\"));
|
||||
if (sep == -1) {
|
||||
return base;
|
||||
}
|
||||
|
|
@ -3840,7 +3828,7 @@ String String::get_base_dir() const {
|
|||
}
|
||||
|
||||
String String::get_file() const {
|
||||
int sep = MAX(find_last("/"), find_last("\\"));
|
||||
int sep = MAX(rfind("/"), rfind("\\"));
|
||||
if (sep == -1) {
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -3849,8 +3837,8 @@ String String::get_file() const {
|
|||
}
|
||||
|
||||
String String::get_extension() const {
|
||||
int pos = find_last(".");
|
||||
if (pos < 0 || pos < MAX(find_last("/"), find_last("\\"))) {
|
||||
int pos = rfind(".");
|
||||
if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
@ -3938,8 +3926,8 @@ String String::property_name_encode() const {
|
|||
}
|
||||
|
||||
String String::get_basename() const {
|
||||
int pos = find_last(".");
|
||||
if (pos < 0 || pos < MAX(find_last("/"), find_last("\\"))) {
|
||||
int pos = rfind(".");
|
||||
if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -202,7 +202,6 @@ public:
|
|||
int find(const String &p_str, int p_from = 0) const; ///< return <0 if failed
|
||||
int find(const char *p_str, int p_from = 0) const; ///< return <0 if failed
|
||||
int find_char(const CharType &p_char, int p_from = 0) const; ///< return <0 if failed
|
||||
int find_last(const String &p_str) const; ///< return <0 if failed
|
||||
int findn(const String &p_str, int p_from = 0) const; ///< return <0 if failed, case insensitive
|
||||
int rfind(const String &p_str, int p_from = -1) const; ///< return <0 if failed
|
||||
int rfindn(const String &p_str, int p_from = -1) const; ///< return <0 if failed, case insensitive
|
||||
|
|
|
|||
|
|
@ -244,7 +244,6 @@ struct _VariantCall {
|
|||
VCALL_LOCALMEM3R(String, countn);
|
||||
VCALL_LOCALMEM2R(String, substr);
|
||||
VCALL_LOCALMEM2R(String, find);
|
||||
VCALL_LOCALMEM1R(String, find_last);
|
||||
VCALL_LOCALMEM2R(String, findn);
|
||||
VCALL_LOCALMEM2R(String, rfind);
|
||||
VCALL_LOCALMEM2R(String, rfindn);
|
||||
|
|
@ -1780,7 +1779,6 @@ void register_variant_methods() {
|
|||
ADDFUNC3R(STRING, INT, String, count, STRING, "what", INT, "from", INT, "to", varray(0, 0));
|
||||
ADDFUNC3R(STRING, INT, String, countn, STRING, "what", INT, "from", INT, "to", varray(0, 0));
|
||||
|
||||
ADDFUNC1R(STRING, INT, String, find_last, STRING, "what", varray());
|
||||
ADDFUNC2R(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0));
|
||||
ADDFUNC2R(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1));
|
||||
ADDFUNC2R(STRING, INT, String, rfindn, STRING, "what", INT, "from", varray(-1));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue