| 29 | namespace fory { |
| 30 | |
| 31 | static 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 | |
| 51 | static inline bool is_latin1_fallback(const uint16_t *data, size_t size) { |
| 52 | for (size_t i = 0; i < size; ++i) { |
no outgoing calls
no test coverage detected