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

Method casecmp_to

core/string/ustring.cpp:503–533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501}
502
503signed 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
535static _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.

Callers 2

_do_reparentMethod · 0.80
test_string.hFile · 0.80

Calls 3

get_dataFunction · 0.85
is_emptyMethod · 0.45
get_dataMethod · 0.45

Tested by

no test coverage detected