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

Method findn

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

Source from the content-addressed store, hash-verified

3638}
3639
3640int String::findn(const String& p_str, int p_from) const
3641{
3642 if (p_from < 0)
3643 {
3644 return -1;
3645 }
3646
3647 int src_len = p_str.length();
3648
3649 if (src_len == 0 || length() == 0)
3650 {
3651 return -1; // won't find anything!
3652 }
3653
3654 const char32_t* srcd = get_data();
3655
3656 for (int i = p_from; i <= (length() - src_len); i++)
3657 {
3658 bool found = true;
3659 for (int j = 0; j < src_len; j++)
3660 {
3661 int read_pos = i + j;
3662
3663 if (read_pos >= length())
3664 {
3665 ERR_PRINT("read_pos>=length()");
3666 return -1;
3667 }
3668
3669 char32_t src = _find_lower(srcd[read_pos]);
3670 char32_t dst = _find_lower(p_str[j]);
3671
3672 if (src != dst)
3673 {
3674 found = false;
3675 break;
3676 }
3677 }
3678
3679 if (found)
3680 {
3681 return i;
3682 }
3683 }
3684
3685 return -1;
3686}
3687
3688int String::rfind(const String& p_str, int p_from) const
3689{

Callers 1

_countMethod · 0.80

Calls 4

_find_lowerFunction · 0.85
lengthFunction · 0.50
get_dataFunction · 0.50
lengthMethod · 0.45

Tested by

no test coverage detected