MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / fastfloat_strncasecmp5

Function fastfloat_strncasecmp5

app/src/ThirdParty/fast_float.h:470–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468
469template <typename UC>
470inline FASTFLOAT_CONSTEXPR14 bool
471fastfloat_strncasecmp5(UC const *actual_mixedcase,
472 UC const *expected_lowercase) {
473 uint64_t mask{0};
474 uint64_t val1{0}, val2{0};
475 if (cpp20_and_in_constexpr()) {
476 for (size_t i = 0; i < 5; i++) {
477 if ((actual_mixedcase[i] | 32) != expected_lowercase[i]) {
478 return false;
479 }
480 }
481 return true;
482 } else {
483 FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 1) {
484 mask = 0x2020202020202020;
485 ::memcpy(&val1, actual_mixedcase, 5 * sizeof(UC));
486 ::memcpy(&val2, expected_lowercase, 5 * sizeof(UC));
487 val1 |= mask;
488 val2 |= mask;
489 return val1 == val2;
490 }
491 else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 2) {
492 mask = 0x0020002000200020;
493 ::memcpy(&val1, actual_mixedcase, 4 * sizeof(UC));
494 ::memcpy(&val2, expected_lowercase, 4 * sizeof(UC));
495 val1 |= mask;
496 if (val1 != val2) {
497 return false;
498 }
499 return (actual_mixedcase[4] | 32) == (expected_lowercase[4]);
500 }
501 else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 4) {
502 mask = 0x0000002000000020;
503 ::memcpy(&val1, actual_mixedcase, 2 * sizeof(UC));
504 ::memcpy(&val2, expected_lowercase, 2 * sizeof(UC));
505 val1 |= mask;
506 if (val1 != val2) {
507 return false;
508 }
509 ::memcpy(&val1, actual_mixedcase + 2, 2 * sizeof(UC));
510 ::memcpy(&val2, expected_lowercase + 2, 2 * sizeof(UC));
511 val1 |= mask;
512 if (val1 != val2) {
513 return false;
514 }
515 return (actual_mixedcase[4] | 32) == (expected_lowercase[4]);
516 }
517 else {
518 return false;
519 }
520 }
521}
522
523// Compares two ASCII strings in a case insensitive manner.
524template <typename UC>

Callers 1

Calls 2

cpp20_and_in_constexprFunction · 0.85
FASTFLOAT_IF_CONSTEXPR17Function · 0.85

Tested by

no test coverage detected