MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / findn

Method findn

core/string/ustring.cpp:3230–3268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3228}
3229
3230int String::findn(const String &p_str, int p_from) const {
3231 if (p_from < 0) {
3232 return -1;
3233 }
3234
3235 int src_len = p_str.length();
3236
3237 if (src_len == 0 || length() == 0) {
3238 return -1; // won't find anything!
3239 }
3240
3241 const char32_t *srcd = get_data();
3242
3243 for (int i = p_from; i <= (length() - src_len); i++) {
3244 bool found = true;
3245 for (int j = 0; j < src_len; j++) {
3246 int read_pos = i + j;
3247
3248 if (read_pos >= length()) {
3249 ERR_PRINT("read_pos>=length()");
3250 return -1;
3251 }
3252
3253 char32_t src = _find_lower(srcd[read_pos]);
3254 char32_t dst = _find_lower(p_str[j]);
3255
3256 if (src != dst) {
3257 found = false;
3258 break;
3259 }
3260 }
3261
3262 if (found) {
3263 return i;
3264 }
3265 }
3266
3267 return -1;
3268}
3269
3270int String::findn(const char *p_str, int p_from) const {
3271 if (p_from < 0) {

Callers 15

_search_lineMethod · 0.80
_search_item_textMethod · 0.80
searchMethod · 0.80
gui_inputMethod · 0.80
requestMethod · 0.80
_countMethod · 0.80
_replace_commonFunction · 0.80
open_internalMethod · 0.80
find_nextFunction · 0.80

Calls 4

get_dataFunction · 0.85
_find_lowerFunction · 0.85
strlenFunction · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected