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

Function fastfloat_strncasecmp

app/src/ThirdParty/fast_float.h:525–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523// Compares two ASCII strings in a case insensitive manner.
524template <typename UC>
525inline FASTFLOAT_CONSTEXPR14 bool
526fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
527 size_t length) {
528 uint64_t mask{0};
529 FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 1) { mask = 0x2020202020202020; }
530 else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 2) {
531 mask = 0x0020002000200020;
532 }
533 else FASTFLOAT_IF_CONSTEXPR17(sizeof(UC) == 4) {
534 mask = 0x0000002000000020;
535 }
536 else {
537 return false;
538 }
539
540 if (cpp20_and_in_constexpr()) {
541 for (size_t i = 0; i < length; i++) {
542 if ((actual_mixedcase[i] | 32) != expected_lowercase[i]) {
543 return false;
544 }
545 }
546 return true;
547 } else {
548 uint64_t val1{0}, val2{0};
549 size_t sz{8 / (sizeof(UC))};
550 for (size_t i = 0; i < length; i += sz) {
551 val1 = val2 = 0;
552 sz = sz < (length - i) ? sz : length - i;
553 ::memcpy(&val1, actual_mixedcase + i, sz * sizeof(UC));
554 ::memcpy(&val2, expected_lowercase + i, sz * sizeof(UC));
555 val1 |= mask;
556 val2 |= mask;
557 if (val1 != val2) {
558 return false;
559 }
560 }
561 return true;
562 }
563}
564
565#ifndef FLT_EVAL_METHOD
566#error "FLT_EVAL_METHOD should be defined, please include cfloat."

Callers

nothing calls this directly

Calls 2

FASTFLOAT_IF_CONSTEXPR17Function · 0.85
cpp20_and_in_constexprFunction · 0.85

Tested by

no test coverage detected