From c303478ad7b096b77bea419c8066a9b263822df4 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 15 Aug 2025 19:45:00 -0400 Subject: [PATCH] Avoid Utf8Dfa scan if there's no non-ascii --- src/parser3.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/parser3.h b/src/parser3.h index 668f983..8de85bc 100644 --- a/src/parser3.h +++ b/src/parser3.h @@ -209,6 +209,7 @@ inline PRESERVE_NONE WeaselJsonStatus scan_string_impl(Parser3 *self, if (self->strDfa.accept()) { for (;;) { if (bufEnd - buf < V::lanes) [[unlikely]] { + buf = (char *)self->strDfa.scan(buf, bufEnd); break; } auto v = V{(int8_t *)buf}; @@ -217,13 +218,16 @@ inline PRESERVE_NONE WeaselJsonStatus scan_string_impl(Parser3 *self, .count_leading_nonzero_lanes(); buf += normal; if (normal < V::lanes) { + if (buf != bufEnd && *buf < 0x20) { + buf = (char *)self->strDfa.scan(buf, bufEnd); + } break; } } + } else { + buf = (char *)self->strDfa.scan(buf, bufEnd); } - buf = (char *)self->strDfa.scan(buf, bufEnd); - int len = buf - before; if (!(self->flags & WeaselJsonRaw)) { if (self->writeBuf != before) {