Skip to content

Commit

Permalink
- json: support for single quotes with simd
Browse files Browse the repository at this point in the history
  • Loading branch information
oknenavin committed Jul 5, 2024
1 parent 1c059e1 commit 21a3234
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cxon/lang/common/cio/char.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ namespace cxon { namespace cio { namespace chr {
}
}
template <typename Y = X>
struct use_simd_ : bool_constant<CXON_USE_SIMD && !Y::produce_strict_javascript> {};
struct use_simd_ : bool_constant<CXON_USE_SIMD && !is_key_context<Y>::value && !Y::produce_strict_javascript> {};
template <typename O, typename Cx, typename Y = X>
static auto range(O& o, const char* f, const char* l, Cx& cx)
-> enable_if_t<( is_unquoted_key_context<X>::value || !Y::assume_no_escapes) && !use_simd_<Y>::value, bool>
Expand Down Expand Up @@ -502,10 +502,15 @@ namespace cxon { namespace cio { namespace chr {
__m128i const v1 = _mm_set1_epi8('"');
__m128i const v2 = _mm_set1_epi8('\\');
__m128i const v3 = _mm_set1_epi8(0x1F);
__m128i const v4 = _mm_set1_epi8('\'');
std::size_t n = l - f;
while (n >= 16) {
__m128i r0 = _mm_loadu_si128((__m128i const*)f);
__m128i r1 = _mm_cmpeq_epi8(r0, v1);
__m128i r1;
CXON_IF_CONSTEXPR (is_quoted_key_context<X>::value || X::string::del == '\"')
r1 = _mm_cmpeq_epi8(r0, v1);
else CXON_IF_CONSTEXPR (is_quoted_key_context<X>::value || X::string::del == '\'')
r1 = _mm_cmpeq_epi8(r0, v4);
__m128i r2 = _mm_cmpeq_epi8(r0, v2);
__m128i r3 = _mm_cmpeq_epi8(_mm_min_epu8(r0, v3), r0);
__m128i r4 = _mm_or_si128(_mm_or_si128(r1, r2), r3);
Expand Down

0 comments on commit 21a3234

Please sign in to comment.