in src/detail/skip_chars_sse42.cpp [60:89]
void skip_any_whitespace_sse42(decode_context &context) {
const auto end = context.end;
auto pos = context.position;
for (; pos < end && json_unaligned_16(pos); ++pos) {
if (!is_space(*pos)) {
context.position = pos;
return;
}
}
alignas(16) static const char CHARS[16] = " \t\n\r";
const auto chars = _mm_load_si128(reinterpret_cast<const __m128i *>(&CHARS[0]));
for (; end - pos >= 16; pos += 16) {
const auto chunk = _mm_load_si128(reinterpret_cast<const __m128i *>(pos));
constexpr auto flags = _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_NEGATIVE_POLARITY | _SIDD_LEAST_SIGNIFICANT;
const auto index = _mm_cmpestri(chars, 4, chunk, 16, flags);
if (index != 16) {
context.position = pos + index;
return;
}
}
while (pos < end && is_space(*pos)) {
++pos;
}
context.position = pos;
}