MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / find

Method find

modules/gui/gui/src/backend/text_server/ustring.cpp:3454–3500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3452}
3453
3454int String::find(const String& p_str, int p_from) const
3455{
3456 if (p_from < 0)
3457 {
3458 return -1;
3459 }
3460
3461 const int src_len = p_str.length();
3462
3463 const int len = length();
3464
3465 if (src_len == 0 || len == 0)
3466 {
3467 return -1; // won't find anything!
3468 }
3469
3470 const char32_t* src = get_data();
3471 const char32_t* str = p_str.get_data();
3472
3473 for (int i = p_from; i <= (len - src_len); i++)
3474 {
3475 bool found = true;
3476 for (int j = 0; j < src_len; j++)
3477 {
3478 int read_pos = i + j;
3479
3480 if (read_pos >= len)
3481 {
3482 ERR_PRINT("read_pos>=len");
3483 return -1;
3484 }
3485
3486 if (src[read_pos] != str[j])
3487 {
3488 found = false;
3489 break;
3490 }
3491 }
3492
3493 if (found)
3494 {
3495 return i;
3496 }
3497 }
3498
3499 return -1;
3500}
3501
3502int String::find(const char* p_str, int p_from) const
3503{

Callers 6

parse_urlMethod · 0.45
find_charMethod · 0.45
_countMethod · 0.45
simplify_pathMethod · 0.45
pad_decimalsMethod · 0.45
pad_zerosMethod · 0.45

Calls 4

lengthFunction · 0.50
get_dataFunction · 0.50
lengthMethod · 0.45
get_dataMethod · 0.45

Tested by

no test coverage detected