1- /* auto-generated on 2023-05-09 17:25:59 -0400. Do not edit! */
1+ /* auto-generated on 2023-05-16 13:48:47 -0400. Do not edit! */
22/* begin file src/ada.cpp */
33#include "ada.h"
44/* begin file src/checkers.cpp */
@@ -9786,6 +9786,11 @@ std::string to_unicode(std::string_view input) {
97869786ADA_POP_DISABLE_WARNINGS
97879787
97889788#include <algorithm>
9789+ #if ADA_NEON
9790+ #include <arm_neon.h>
9791+ #elif ADA_SSE2
9792+ #include <emmintrin.h>
9793+ #endif
97899794
97909795namespace ada::unicode {
97919796
@@ -9817,8 +9822,58 @@ constexpr bool to_lower_ascii(char* input, size_t length) noexcept {
98179822 }
98189823 return non_ascii == 0;
98199824}
9820-
9821- ada_really_inline constexpr bool has_tabs_or_newline(
9825+ #if ADA_NEON
9826+ ada_really_inline bool has_tabs_or_newline(
9827+ std::string_view user_input) noexcept {
9828+ size_t i = 0;
9829+ const uint8x16_t mask1 = vmovq_n_u8('\r');
9830+ const uint8x16_t mask2 = vmovq_n_u8('\n');
9831+ const uint8x16_t mask3 = vmovq_n_u8('\t');
9832+ uint8x16_t running{0};
9833+ for (; i + 15 < user_input.size(); i += 16) {
9834+ uint8x16_t word = vld1q_u8((const uint8_t*)user_input.data() + i);
9835+ running = vorrq_u8(vorrq_u8(running, vorrq_u8(vceqq_u8(word, mask1),
9836+ vceqq_u8(word, mask2))),
9837+ vceqq_u8(word, mask3));
9838+ }
9839+ if (i < user_input.size()) {
9840+ uint8_t buffer[16]{};
9841+ memcpy(buffer, user_input.data() + i, user_input.size() - i);
9842+ uint8x16_t word = vld1q_u8((const uint8_t*)user_input.data() + i);
9843+ running = vorrq_u8(vorrq_u8(running, vorrq_u8(vceqq_u8(word, mask1),
9844+ vceqq_u8(word, mask2))),
9845+ vceqq_u8(word, mask3));
9846+ }
9847+ return vmaxvq_u8(running) != 0;
9848+ }
9849+ #elif ADA_SSE2
9850+ ada_really_inline bool has_tabs_or_newline(
9851+ std::string_view user_input) noexcept {
9852+ size_t i = 0;
9853+ const __m128i mask1 = _mm_set1_epi8('\r');
9854+ const __m128i mask2 = _mm_set1_epi8('\n');
9855+ const __m128i mask3 = _mm_set1_epi8('\t');
9856+ __m128i running{0};
9857+ for (; i + 15 < user_input.size(); i += 16) {
9858+ __m128i word = _mm_loadu_si128((const __m128i*)(user_input.data() + i));
9859+ running = _mm_or_si128(
9860+ _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
9861+ _mm_cmpeq_epi8(word, mask2))),
9862+ _mm_cmpeq_epi8(word, mask3));
9863+ }
9864+ if (i < user_input.size()) {
9865+ uint8_t buffer[16]{};
9866+ memcpy(buffer, user_input.data() + i, user_input.size() - i);
9867+ __m128i word = _mm_loadu_si128((const __m128i*)buffer);
9868+ running = _mm_or_si128(
9869+ _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
9870+ _mm_cmpeq_epi8(word, mask2))),
9871+ _mm_cmpeq_epi8(word, mask3));
9872+ }
9873+ return _mm_movemask_epi8(running) != 0;
9874+ }
9875+ #else
9876+ ada_really_inline bool has_tabs_or_newline(
98229877 std::string_view user_input) noexcept {
98239878 auto has_zero_byte = [](uint64_t v) {
98249879 return ((v - 0x0101010101010101) & ~(v)&0x8080808080808080);
@@ -9849,6 +9904,7 @@ ada_really_inline constexpr bool has_tabs_or_newline(
98499904 }
98509905 return running;
98519906}
9907+ #endif
98529908
98539909// A forbidden host code point is U+0000 NULL, U+0009 TAB, U+000A LF, U+000D CR,
98549910// U+0020 SPACE, U+0023 (#), U+002F (/), U+003A (:), U+003C (<), U+003E (>),
@@ -13732,8 +13788,11 @@ bool url_aggregator::set_hostname(const std::string_view input) {
1373213788
1373313789[[nodiscard]] std::string_view url_aggregator::get_host() const noexcept {
1373413790 ada_log("url_aggregator::get_host");
13791+ // Technically, we should check if there is a hostname, but
13792+ // the code below works even if there isn't.
13793+ // if(!has_hostname()) { return ""; }
1373513794 size_t start = components.host_start;
13736- if (buffer.size() > components.host_start &&
13795+ if (components.host_end > components.host_start &&
1373713796 buffer[components.host_start] == '@') {
1373813797 start++;
1373913798 }
@@ -13747,9 +13806,12 @@ bool url_aggregator::set_hostname(const std::string_view input) {
1374713806
1374813807[[nodiscard]] std::string_view url_aggregator::get_hostname() const noexcept {
1374913808 ada_log("url_aggregator::get_hostname");
13809+ // Technically, we should check if there is a hostname, but
13810+ // the code below works even if there isn't.
13811+ // if(!has_hostname()) { return ""; }
1375013812 size_t start = components.host_start;
1375113813 // So host_start is not where the host begins.
13752- if (buffer.size() > components.host_start &&
13814+ if (components.host_end > components.host_start &&
1375313815 buffer[components.host_start] == '@') {
1375413816 start++;
1375513817 }
0 commit comments