in src/detail/skip_chars_sse42.cpp [29:58]
void skip_any_simple_characters_sse42(decode_context &context) {
const auto end = context.end;
auto pos = context.position;
JSON_STRING_SKIP_N_SIMPLE(1, 2, uint8_t, if, done_x)
JSON_STRING_SKIP_N_SIMPLE(2, 4, uint16_t, if, done_2)
JSON_STRING_SKIP_N_SIMPLE(4, 8, uint32_t, if, done_4)
JSON_STRING_SKIP_N_SIMPLE(8, 16, uint64_t, if, done_8)
{
alignas(16) static const char CHARS[16] = "\"\\";
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_POSITIVE_POLARITY | _SIDD_LEAST_SIGNIFICANT;
const auto index = _mm_cmpestri(chars, 2, chunk, 16, flags);
if (index != 16) {
context.position = pos + index;
return;
}
}
}
JSON_STRING_SKIP_N_SIMPLE(8, x, uint64_t, while, done_8)
done_8: JSON_STRING_SKIP_N_SIMPLE(4, x, uint32_t, while, done_4)
done_4: JSON_STRING_SKIP_N_SIMPLE(2, x, uint16_t, while, done_2)
done_2: JSON_STRING_SKIP_N_SIMPLE(1, x, uint8_t, while, done_x)
done_x: context.position = pos;
}