/src/simdutf/src/generic/ascii_validation.h
Line | Count | Source |
1 | | namespace simdutf { |
2 | | namespace SIMDUTF_IMPLEMENTATION { |
3 | | namespace { |
4 | | namespace ascii_validation { |
5 | | |
6 | 0 | result generic_validate_ascii_with_errors(const char *input, size_t length) { |
7 | 0 | buf_block_reader<64> reader(reinterpret_cast<const uint8_t *>(input), length); |
8 | 0 | size_t count{0}; |
9 | 0 | while (reader.has_full_block()) { |
10 | 0 | simd::simd8x64<uint8_t> in(reader.full_block()); |
11 | 0 | if (!in.is_ascii()) { |
12 | 0 | result res = scalar::ascii::validate_with_errors( |
13 | 0 | reinterpret_cast<const char *>(input + count), length - count); |
14 | 0 | return result(res.error, count + res.count); |
15 | 0 | } |
16 | 0 | reader.advance(); |
17 | |
|
18 | 0 | count += 64; |
19 | 0 | } |
20 | 0 | uint8_t block[64]{}; |
21 | 0 | reader.get_remainder(block); |
22 | 0 | simd::simd8x64<uint8_t> in(block); |
23 | 0 | if (!in.is_ascii()) { |
24 | 0 | result res = scalar::ascii::validate_with_errors( |
25 | 0 | reinterpret_cast<const char *>(input + count), length - count); |
26 | 0 | return result(res.error, count + res.count); |
27 | 0 | } else { |
28 | 0 | return result(error_code::SUCCESS, length); |
29 | 0 | } |
30 | 0 | } Unexecuted instantiation: simdutf.cpp:simdutf::haswell::(anonymous namespace)::ascii_validation::generic_validate_ascii_with_errors(char const*, unsigned long) Unexecuted instantiation: simdutf.cpp:simdutf::westmere::(anonymous namespace)::ascii_validation::generic_validate_ascii_with_errors(char const*, unsigned long) |
31 | | |
32 | 0 | bool generic_validate_ascii(const char *input, size_t length) { |
33 | 0 | buf_block_reader<64> reader(reinterpret_cast<const uint8_t *>(input), length); |
34 | 0 | while (reader.has_full_block()) { |
35 | 0 | simd::simd8x64<uint8_t> in(reader.full_block()); |
36 | 0 | if (!in.is_ascii()) { |
37 | 0 | return false; |
38 | 0 | } |
39 | 0 | reader.advance(); |
40 | 0 | } |
41 | 0 | uint8_t block[64]{}; |
42 | 0 | reader.get_remainder(block); |
43 | 0 | simd::simd8x64<uint8_t> in(block); |
44 | 0 | return in.is_ascii(); |
45 | 0 | } Unexecuted instantiation: simdutf.cpp:simdutf::haswell::(anonymous namespace)::ascii_validation::generic_validate_ascii(char const*, unsigned long) Unexecuted instantiation: simdutf.cpp:simdutf::westmere::(anonymous namespace)::ascii_validation::generic_validate_ascii(char const*, unsigned long) |
46 | | |
47 | | } // namespace ascii_validation |
48 | | } // unnamed namespace |
49 | | } // namespace SIMDUTF_IMPLEMENTATION |
50 | | } // namespace simdutf |