diff --git a/src/parser3.h b/src/parser3.h index e9bfac6..5ba8c08 100644 --- a/src/parser3.h +++ b/src/parser3.h @@ -788,18 +788,20 @@ inline PRESERVE_NONE WeaselJsonStatus scan_string_impl(Parser3 *self, char *bufEnd) { const auto before = buf; - // Advance buf past normal characters - for (;;) { - if (bufEnd - buf < V::lanes) [[unlikely]] { - break; - } - auto v = V{(int8_t *)buf}; - int normal = - (v != V::splat('"') & v != V::splat('\\') & v >= V::splat(0x20)) - .count_leading_nonzero_lanes(); - buf += normal; - if (normal < V::lanes) { - break; + // Advance buf past characters that transition the accept state to itself + if (self->strDfa.accept()) { + for (;;) { + if (bufEnd - buf < V::lanes) [[unlikely]] { + break; + } + auto v = V{(int8_t *)buf}; + int normal = + (v != V::splat('"') & v != V::splat('\\') & v >= V::splat(0x20)) + .count_leading_nonzero_lanes(); + buf += normal; + if (normal < V::lanes) { + break; + } } }