simdjson 4.4.0
Ridiculously Fast JSON
Loading...
Searching...
No Matches
stringparsing_defs.h
1#ifndef SIMDJSON_RVV_VLS_STRINGPARSING_DEFS_H
2#define SIMDJSON_RVV_VLS_STRINGPARSING_DEFS_H
3
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#include "simdjson/rvv-vls/base.h"
6#endif // SIMDJSON_CONDITIONAL_INCLUDE
7
8namespace simdjson {
9namespace rvv_vls {
10namespace {
11
12using namespace simd;
13
14// Holds backslashes and quotes locations.
15struct backslash_and_quote {
16public:
17 static constexpr uint64_t BYTES_PROCESSED = sizeof(simd8<uint8_t>);
18 simdjson_inline backslash_and_quote copy_and_find(const uint8_t *src, uint8_t *dst);
19
20 simdjson_inline bool has_quote_first() { return ((bs_bits - 1) & quote_bits) != 0; }
21 simdjson_inline bool has_backslash() { return ((quote_bits - 1) & bs_bits) != 0; }
22 simdjson_inline int quote_index() { return trailing_zeroes(quote_bits); }
23 simdjson_inline int backslash_index() { return trailing_zeroes(bs_bits); }
24
25 uint64_t bs_bits;
26 uint64_t quote_bits;
27}; // struct backslash_and_quote
28
29simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) {
30 static_assert(SIMDJSON_PADDING >= (BYTES_PROCESSED - 1), "backslash and quote finder must process fewer than SIMDJSON_PADDING bytes");
31 simd8<uint8_t> v(src);
32 v.store(dst);
33 return { (v == '\\').to_bitmask(), (v == '"').to_bitmask() };
34}
35
36struct escaping {
37 static constexpr uint64_t BYTES_PROCESSED = sizeof(simd8<uint8_t>);
38 simdjson_inline static escaping copy_and_find(const uint8_t *src, uint8_t *dst);
39
40 simdjson_inline bool has_escape() { return escape_bits != 0; }
41 simdjson_inline int escape_index() { return trailing_zeroes(escape_bits) / 4; }
42
43 uint64_t escape_bits;
44}; // struct escaping
45
46simdjson_inline escaping escaping::copy_and_find(const uint8_t *src, uint8_t *dst) {
47 static_assert(SIMDJSON_PADDING >= (BYTES_PROCESSED - 1), "escaping finder must process fewer than SIMDJSON_PADDING bytes");
48 simd8<uint8_t> v(src);
49 v.store(dst);
50 return { ((v == '"') | (v == '\\') | (v == 32)).to_bitmask() };
51}
52
53
54} // unnamed namespace
55} // namespace rvv_vls
56} // namespace simdjson
57
58#endif // SIMDJSON_RVV_VLS_STRINGPARSING_DEFS_H
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8
constexpr size_t SIMDJSON_PADDING
The amount of padding needed in a buffer to parse JSON.
Definition base.h:33