MCPcopy Create free account
hub / github.com/apache/fory / is_ascii_fallback

Function is_ascii_fallback

cpp/fory/util/string_util.h:31–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace fory {
30
31static inline bool is_ascii_fallback(const char *data, size_t size) {
32 size_t i = 0;
33 // Loop through 8-byte chunks
34 for (; i + 7 < size; i += 8) {
35 // Load 8 bytes from the string
36 uint64_t chunk = *reinterpret_cast<const uint64_t *>(data + i);
37 // Check if any byte in the 64-bit chunk is >= 128
38 // This checks if any of the top bits of each byte are set
39 if (chunk & 0x8080808080808080ULL) {
40 return false;
41 }
42 }
43 for (; i < size; ++i) {
44 if (static_cast<unsigned char>(data[i]) >= 128) {
45 return false;
46 }
47 }
48 return true;
49}
50
51static inline bool is_latin1_fallback(const uint16_t *data, size_t size) {
52 for (size_t i = 0; i < size; ++i) {

Callers 2

latin1_to_utf8Function · 0.85
is_asciiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected