1
- /* auto-generated on 2023-09-19 16:48:25 -0400. Do not edit! */
1
+ /* auto-generated on 2023-09-30 20:34:30 -0400. Do not edit! */
2
2
/* begin file src/ada.cpp */
3
3
#include "ada.h"
4
4
/* begin file src/checkers.cpp */
@@ -116,7 +116,7 @@ ada_really_inline constexpr bool verify_dns_length(
116
116
117
117
ADA_PUSH_DISABLE_ALL_WARNINGS
118
118
/* begin file src/ada_idna.cpp */
119
- /* auto-generated on 2023-08-29 15:28:19 -0400. Do not edit! */
119
+ /* auto-generated on 2023-09-19 15:58:51 -0400. Do not edit! */
120
120
/* begin file src/idna.cpp */
121
121
/* begin file src/unicode_transcoding.cpp */
122
122
@@ -9505,18 +9505,19 @@ bool is_label_valid(const std::u32string_view label) {
9505
9505
9506
9506
namespace ada::idna {
9507
9507
9508
- bool constexpr begins_with(std::u32string_view view,
9509
- std::u32string_view prefix) {
9508
+ bool begins_with(std::u32string_view view, std::u32string_view prefix) {
9510
9509
if (view.size() < prefix.size()) {
9511
9510
return false;
9512
9511
}
9512
+ // constexpr as of C++20
9513
9513
return std::equal(prefix.begin(), prefix.end(), view.begin());
9514
9514
}
9515
9515
9516
- bool constexpr begins_with(std::string_view view, std::string_view prefix) {
9516
+ bool begins_with(std::string_view view, std::string_view prefix) {
9517
9517
if (view.size() < prefix.size()) {
9518
9518
return false;
9519
9519
}
9520
+ // constexpr as of C++20
9520
9521
return std::equal(prefix.begin(), prefix.end(), view.begin());
9521
9522
}
9522
9523
@@ -9809,6 +9810,17 @@ constexpr bool to_lower_ascii(char* input, size_t length) noexcept {
9809
9810
#if ADA_NEON
9810
9811
ada_really_inline bool has_tabs_or_newline(
9811
9812
std::string_view user_input) noexcept {
9813
+ // first check for short strings in which case we do it naively.
9814
+ if (user_input.size() < 16) { // slow path
9815
+ for (size_t i = 0; i < user_input.size(); i++) {
9816
+ if (user_input[i] == '\r' || user_input[i] == '\n' ||
9817
+ user_input[i] == '\t') {
9818
+ return true;
9819
+ }
9820
+ }
9821
+ return false;
9822
+ }
9823
+ // fast path for long strings (expected to be common)
9812
9824
size_t i = 0;
9813
9825
const uint8x16_t mask1 = vmovq_n_u8('\r');
9814
9826
const uint8x16_t mask2 = vmovq_n_u8('\n');
@@ -9821,9 +9833,8 @@ ada_really_inline bool has_tabs_or_newline(
9821
9833
vceqq_u8(word, mask3));
9822
9834
}
9823
9835
if (i < user_input.size()) {
9824
- uint8_t buffer[16]{};
9825
- memcpy(buffer, user_input.data() + i, user_input.size() - i);
9826
- uint8x16_t word = vld1q_u8((const uint8_t*)user_input.data() + i);
9836
+ uint8x16_t word =
9837
+ vld1q_u8((const uint8_t*)user_input.data() + user_input.length() - 16);
9827
9838
running = vorrq_u8(vorrq_u8(running, vorrq_u8(vceqq_u8(word, mask1),
9828
9839
vceqq_u8(word, mask2))),
9829
9840
vceqq_u8(word, mask3));
@@ -9833,6 +9844,17 @@ ada_really_inline bool has_tabs_or_newline(
9833
9844
#elif ADA_SSE2
9834
9845
ada_really_inline bool has_tabs_or_newline(
9835
9846
std::string_view user_input) noexcept {
9847
+ // first check for short strings in which case we do it naively.
9848
+ if (user_input.size() < 16) { // slow path
9849
+ for (size_t i = 0; i < user_input.size(); i++) {
9850
+ if (user_input[i] == '\r' || user_input[i] == '\n' ||
9851
+ user_input[i] == '\t') {
9852
+ return true;
9853
+ }
9854
+ }
9855
+ return false;
9856
+ }
9857
+ // fast path for long strings (expected to be common)
9836
9858
size_t i = 0;
9837
9859
const __m128i mask1 = _mm_set1_epi8('\r');
9838
9860
const __m128i mask2 = _mm_set1_epi8('\n');
@@ -9846,9 +9868,8 @@ ada_really_inline bool has_tabs_or_newline(
9846
9868
_mm_cmpeq_epi8(word, mask3));
9847
9869
}
9848
9870
if (i < user_input.size()) {
9849
- alignas(16) uint8_t buffer[16]{};
9850
- memcpy(buffer, user_input.data() + i, user_input.size() - i);
9851
- __m128i word = _mm_load_si128((const __m128i*)buffer);
9871
+ __m128i word = _mm_loadu_si128(
9872
+ (const __m128i*)(user_input.data() + user_input.length() - 16));
9852
9873
running = _mm_or_si128(
9853
9874
_mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
9854
9875
_mm_cmpeq_epi8(word, mask2))),
0 commit comments