| 501 | } |
| 502 | |
| 503 | signed char String::casecmp_to(const String &p_str) const { |
| 504 | if (is_empty() && p_str.is_empty()) { |
| 505 | return 0; |
| 506 | } |
| 507 | if (is_empty()) { |
| 508 | return -1; |
| 509 | } |
| 510 | if (p_str.is_empty()) { |
| 511 | return 1; |
| 512 | } |
| 513 | |
| 514 | const char32_t *that_str = p_str.get_data(); |
| 515 | const char32_t *this_str = get_data(); |
| 516 | |
| 517 | while (true) { |
| 518 | if (*that_str == 0 && *this_str == 0) { // If both strings are at the end, they are equal. |
| 519 | return 0; |
| 520 | } else if (*this_str == 0) { // If at the end of this, and not of other, we are less. |
| 521 | return -1; |
| 522 | } else if (*that_str == 0) { // If at end of other, and not of this, we are greater. |
| 523 | return 1; |
| 524 | } else if (*this_str < *that_str) { // If current character in this is less, we are less. |
| 525 | return -1; |
| 526 | } else if (*this_str > *that_str) { // If current character in this is greater, we are greater. |
| 527 | return 1; |
| 528 | } |
| 529 | |
| 530 | this_str++; |
| 531 | that_str++; |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | static _FORCE_INLINE_ signed char natural_cmp_common(const char32_t *&r_this_str, const char32_t *&r_that_str) { |
| 536 | // Keep ptrs to start of numerical sequences. |
no test coverage detected