| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c6a7525 commit f7c4daa
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - /* auto-generated on 2023-05-08 12:41:03 -0400. Do not edit! */ | ||
| 1 | + /* auto-generated on 2023-05-16 13:48:47 -0400. Do not edit! */ | ||
| 2 | 2 | /* begin file src/ada.cpp */ | |
| 3 | 3 | #include "ada.h" | |
| 4 | 4 | /* begin file src/checkers.cpp */ | |
@@ -9786,6 +9786,11 @@ std::string to_unicode(std::string_view input) { | |||
| 9786 | 9786 | ADA_POP_DISABLE_WARNINGS | |
| 9787 | 9787 | ||
| 9788 | 9788 | #include <algorithm> | |
| 9789 | + #if ADA_NEON | ||
| 9790 | + #include <arm_neon.h> | ||
| 9791 | + #elif ADA_SSE2 | ||
| 9792 | + #include <emmintrin.h> | ||
| 9793 | + #endif | ||
| 9789 | 9794 | ||
| 9790 | 9795 | namespace ada::unicode { | |
| 9791 | 9796 | ||
@@ -9817,8 +9822,58 @@ constexpr bool to_lower_ascii(char* input, size_t length) noexcept { | |||
| 9817 | 9822 | } | |
| 9818 | 9823 | return non_ascii == 0; | |
| 9819 | 9824 | } | |
| 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( | ||
| 9822 | 9877 | std::string_view user_input) noexcept { | |
| 9823 | 9878 | auto has_zero_byte = [](uint64_t v) { | |
| 9824 | 9879 | return ((v - 0x0101010101010101) & ~(v)&0x8080808080808080); | |
@@ -9849,6 +9904,7 @@ ada_really_inline constexpr bool has_tabs_or_newline( | |||
| 9849 | 9904 | } | |
| 9850 | 9905 | return running; | |
| 9851 | 9906 | } | |
| 9907 | + #endif | ||
| 9852 | 9908 | ||
| 9853 | 9909 | // A forbidden host code point is U+0000 NULL, U+0009 TAB, U+000A LF, U+000D CR, | |
| 9854 | 9910 | // 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) { | |||
| 13732 | 13788 | ||
| 13733 | 13789 | [[nodiscard]] std::string_view url_aggregator::get_host() const noexcept { | |
| 13734 | 13790 | 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 ""; } | ||
| 13735 | 13794 | size_t start = components.host_start; | |
| 13736 | - if (buffer.size() > components.host_start && | ||
| 13795 | + if (components.host_end > components.host_start && | ||
| 13737 | 13796 | buffer[components.host_start] == '@') { | |
| 13738 | 13797 | start++; | |
| 13739 | 13798 | } | |
@@ -13747,9 +13806,12 @@ bool url_aggregator::set_hostname(const std::string_view input) { | |||
| 13747 | 13806 | ||
| 13748 | 13807 | [[nodiscard]] std::string_view url_aggregator::get_hostname() const noexcept { | |
| 13749 | 13808 | 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 ""; } | ||
| 13750 | 13812 | size_t start = components.host_start; | |
| 13751 | 13813 | // So host_start is not where the host begins. | |
| 13752 | - if (buffer.size() > components.host_start && | ||
| 13814 | + if (components.host_end > components.host_start && | ||
| 13753 | 13815 | buffer[components.host_start] == '@') { | |
| 13754 | 13816 | start++; | |
| 13755 | 13817 | } | |
@@ -14807,17 +14869,32 @@ struct ada_url_components { | |||
| 14807 | 14869 | uint32_t hash_start; | |
| 14808 | 14870 | }; | |
| 14809 | 14871 | ||
| 14810 | - ada_url ada_parse(const char* input) noexcept { | ||
| 14872 | + ada_url ada_parse(const char* input, size_t length) noexcept { | ||
| 14811 | 14873 | return new ada::result<ada::url_aggregator>( | |
| 14812 | - ada::parse<ada::url_aggregator>(input)); | ||
| 14874 | + ada::parse<ada::url_aggregator>(std::string_view(input, length))); | ||
| 14813 | 14875 | } | |
| 14814 | 14876 | ||
| 14815 | - bool ada_can_parse(const char* input, const char* base) noexcept { | ||
| 14816 | - if (base == nullptr) { | ||
| 14817 | - return ada::can_parse(input); | ||
| 14877 | + ada_url ada_parse_with_base(const char* input, size_t input_length, | ||
| 14878 | + const char* base, size_t base_length) noexcept { | ||
| 14879 | + auto base_out = | ||
| 14880 | + ada::parse<ada::url_aggregator>(std::string_view(base, base_length)); | ||
| 14881 | + | ||
| 14882 | + if (!base_out) { | ||
| 14883 | + return new ada::result<ada::url_aggregator>(base_out); | ||
| 14818 | 14884 | } | |
| 14819 | - std::string_view sv(base); | ||
| 14820 | - return ada::can_parse(input, &sv); | ||
| 14885 | + | ||
| 14886 | + return new ada::result<ada::url_aggregator>(ada::parse<ada::url_aggregator>( | ||
| 14887 | + std::string_view(input, input_length), &base_out.value())); | ||
| 14888 | + } | ||
| 14889 | + | ||
| 14890 | + bool ada_can_parse(const char* input, size_t length) noexcept { | ||
| 14891 | + return ada::can_parse(std::string_view(input, length)); | ||
| 14892 | + } | ||
| 14893 | + | ||
| 14894 | + bool ada_can_parse_with_base(const char* input, size_t input_length, | ||
| 14895 | + const char* base, size_t base_length) noexcept { | ||
| 14896 | + auto base_view = std::string_view(base, base_length); | ||
| 14897 | + return ada::can_parse(std::string_view(input, input_length), &base_view); | ||
| 14821 | 14898 | } | |
| 14822 | 14899 | ||
| 14823 | 14900 | void ada_free(ada_url result) noexcept { | |
@@ -14943,81 +15020,86 @@ ada_string ada_get_protocol(ada_url result) noexcept { | |||
| 14943 | 15020 | return ada_string_create(out.data(), out.length()); | |
| 14944 | 15021 | } | |
| 14945 | 15022 | ||
| 14946 | - bool ada_set_href(ada_url result, const char* input) noexcept { | ||
| 15023 | + bool ada_set_href(ada_url result, const char* input, size_t length) noexcept { | ||
| 14947 | 15024 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 14948 | 15025 | if (!r) { | |
| 14949 | 15026 | return false; | |
| 14950 | 15027 | } | |
| 14951 | - return r->set_href(input); | ||
| 15028 | + return r->set_href(std::string_view(input, length)); | ||
| 14952 | 15029 | } | |
| 14953 | 15030 | ||
| 14954 | - bool ada_set_host(ada_url result, const char* input) noexcept { | ||
| 15031 | + bool ada_set_host(ada_url result, const char* input, size_t length) noexcept { | ||
| 14955 | 15032 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 14956 | 15033 | if (!r) { | |
| 14957 | 15034 | return false; | |
| 14958 | 15035 | } | |
| 14959 | - return r->set_host(input); | ||
| 15036 | + return r->set_host(std::string_view(input, length)); | ||
| 14960 | 15037 | } | |
| 14961 | 15038 | ||
| 14962 | - bool ada_set_hostname(ada_url result, const char* input) noexcept { | ||
| 15039 | + bool ada_set_hostname(ada_url result, const char* input, | ||
| 15040 | + size_t length) noexcept { | ||
| 14963 | 15041 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 14964 | 15042 | if (!r) { | |
| 14965 | 15043 | return false; | |
| 14966 | 15044 | } | |
| 14967 | - return r->set_hostname(input); | ||
| 15045 | + return r->set_hostname(std::string_view(input, length)); | ||
| 14968 | 15046 | } | |
| 14969 | 15047 | ||
| 14970 | - bool ada_set_protocol(ada_url result, const char* input) noexcept { | ||
| 15048 | + bool ada_set_protocol(ada_url result, const char* input, | ||
| 15049 | + size_t length) noexcept { | ||
| 14971 | 15050 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 14972 | 15051 | if (!r) { | |
| 14973 | 15052 | return false; | |
| 14974 | 15053 | } | |
| 14975 | - return r->set_protocol(input); | ||
| 15054 | + return r->set_protocol(std::string_view(input, length)); | ||
| 14976 | 15055 | } | |
| 14977 | 15056 | ||
| 14978 | - bool ada_set_username(ada_url result, const char* input) noexcept { | ||
| 15057 | + bool ada_set_username(ada_url result, const char* input, | ||
| 15058 | + size_t length) noexcept { | ||
| 14979 | 15059 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 14980 | 15060 | if (!r) { | |
| 14981 | 15061 | return false; | |
| 14982 | 15062 | } | |
| 14983 | - return r->set_username(input); | ||
| 15063 | + return r->set_username(std::string_view(input, length)); | ||
| 14984 | 15064 | } | |
| 14985 | 15065 | ||
| 14986 | - bool ada_set_password(ada_url result, const char* input) noexcept { | ||
| 15066 | + bool ada_set_password(ada_url result, const char* input, | ||
| 15067 | + size_t length) noexcept { | ||
| 14987 | 15068 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 14988 | 15069 | if (!r) { | |
| 14989 | 15070 | return false; | |
| 14990 | 15071 | } | |
| 14991 | - return r->set_password(input); | ||
| 15072 | + return r->set_password(std::string_view(input, length)); | ||
| 14992 | 15073 | } | |
| 14993 | 15074 | ||
| 14994 | - bool ada_set_port(ada_url result, const char* input) noexcept { | ||
| 15075 | + bool ada_set_port(ada_url result, const char* input, size_t length) noexcept { | ||
| 14995 | 15076 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 14996 | 15077 | if (!r) { | |
| 14997 | 15078 | return false; | |
| 14998 | 15079 | } | |
| 14999 | - return r->set_port(input); | ||
| 15080 | + return r->set_port(std::string_view(input, length)); | ||
| 15000 | 15081 | } | |
| 15001 | 15082 | ||
| 15002 | - bool ada_set_pathname(ada_url result, const char* input) noexcept { | ||
| 15083 | + bool ada_set_pathname(ada_url result, const char* input, | ||
| 15084 | + size_t length) noexcept { | ||
| 15003 | 15085 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 15004 | 15086 | if (!r) { | |
| 15005 | 15087 | return false; | |
| 15006 | 15088 | } | |
| 15007 | - return r->set_pathname(input); | ||
| 15089 | + return r->set_pathname(std::string_view(input, length)); | ||
| 15008 | 15090 | } | |
| 15009 | 15091 | ||
| 15010 | - void ada_set_search(ada_url result, const char* input) noexcept { | ||
| 15092 | + void ada_set_search(ada_url result, const char* input, size_t length) noexcept { | ||
| 15011 | 15093 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 15012 | 15094 | if (r) { | |
| 15013 | - r->set_search(input); | ||
| 15095 | + r->set_search(std::string_view(input, length)); | ||
| 15014 | 15096 | } | |
| 15015 | 15097 | } | |
| 15016 | 15098 | ||
| 15017 | - void ada_set_hash(ada_url result, const char* input) noexcept { | ||
| 15099 | + void ada_set_hash(ada_url result, const char* input, size_t length) noexcept { | ||
| 15018 | 15100 | ada::result<ada::url_aggregator>& r = get_instance(result); | |
| 15019 | 15101 | if (r) { | |
| 15020 | - r->set_hash(input); | ||
| 15102 | + r->set_hash(std::string_view(input, length)); | ||
| 15021 | 15103 | } | |
| 15022 | 15104 | } | |
| 15023 | 15105 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - /* auto-generated on 2023-05-08 12:41:03 -0400. Do not edit! */ | ||
| 1 | + /* auto-generated on 2023-05-16 13:48:47 -0400. Do not edit! */ | ||
| 2 | 2 | /* begin file include/ada.h */ | |
| 3 | 3 | /** | |
| 4 | 4 | * @file ada.h | |
@@ -468,6 +468,17 @@ namespace ada { | |||
| 468 | 468 | if (!(COND)) __builtin_unreachable(); \ | |
| 469 | 469 | } while (0) | |
| 470 | 470 | #endif | |
| 471 | + | ||
| 472 | + #if defined(__SSE2__) || defined(__x86_64__) || defined(__x86_64) || \ | ||
| 473 | + (defined(_M_AMD64) || defined(_M_X64) || \ | ||
| 474 | + (defined(_M_IX86_FP) && _M_IX86_FP == 2)) | ||
| 475 | + #define ADA_SSE2 1 | ||
| 476 | + #endif | ||
| 477 | + | ||
| 478 | + #if defined(__aarch64__) || defined(_M_ARM64) | ||
| 479 | + #define ADA_NEON 1 | ||
| 480 | + #endif | ||
| 481 | + | ||
| 471 | 482 | #endif // ADA_COMMON_DEFS_H | |
| 472 | 483 | /* end file include/ada/common_defs.h */ | |
| 473 | 484 | #include <stdint.h> | |
@@ -4320,7 +4331,7 @@ std::string to_unicode(std::string_view input); | |||
| 4320 | 4331 | * @attention The has_tabs_or_newline function is a bottleneck and it is simple | |
| 4321 | 4332 | * enough that compilers like GCC can 'autovectorize it'. | |
| 4322 | 4333 | */ | |
| 4323 | - ada_really_inline constexpr bool has_tabs_or_newline( | ||
| 4334 | + ada_really_inline bool has_tabs_or_newline( | ||
| 4324 | 4335 | std::string_view user_input) noexcept; | |
| 4325 | 4336 | ||
| 4326 | 4337 | /** | |
@@ -6473,14 +6484,14 @@ inline std::ostream &operator<<(std::ostream &out, | |||
| 6473 | 6484 | #ifndef ADA_ADA_VERSION_H | |
| 6474 | 6485 | #define ADA_ADA_VERSION_H | |
| 6475 | 6486 | ||
| 6476 | - #define ADA_VERSION "2.4.0" | ||
| 6487 | + #define ADA_VERSION "2.4.1" | ||
| 6477 | 6488 | ||
| 6478 | 6489 | namespace ada { | |
| 6479 | 6490 | ||
| 6480 | 6491 | enum { | |
| 6481 | 6492 | ADA_VERSION_MAJOR = 2, | |
| 6482 | 6493 | ADA_VERSION_MINOR = 4, | |
| 6483 | - ADA_VERSION_REVISION = 0, | ||
| 6494 | + ADA_VERSION_REVISION = 1, | ||
| 6484 | 6495 | }; | |
| 6485 | 6496 | ||
| 6486 | 6497 | } // namespace ada | |
@@ -6508,11 +6519,11 @@ using result = tl::expected<result_type, ada::errors>; | |||
| 6508 | 6519 | ||
| 6509 | 6520 | /** | |
| 6510 | 6521 | * The URL parser takes a scalar value string input, with an optional null or | |
| 6511 | - * base URL base (default null). The parser assumes the input has an UTF-8 | ||
| 6512 | - * encoding. | ||
| 6522 | + * base URL base (default null). The parser assumes the input is a valid ASCII | ||
| 6523 | + * or UTF-8 string. | ||
| 6513 | 6524 | * | |
| 6514 | - * @param input the string input to analyze. | ||
| 6515 | - * @param base_url the optional string input to use as a base url. | ||
| 6525 | + * @param input the string input to analyze (must be valid ASCII or UTF-8) | ||
| 6526 | + * @param base_url the optional URL input to use as a base url. | ||
| 6516 | 6527 | * @return a parsed URL. | |
| 6517 | 6528 | */ | |
| 6518 | 6529 | template <class result_type = ada::url_aggregator> | |
@@ -6525,14 +6536,17 @@ extern template ada::result<url_aggregator> parse<url_aggregator>( | |||
| 6525 | 6536 | std::string_view input, const url_aggregator* base_url); | |
| 6526 | 6537 | ||
| 6527 | 6538 | /** | |
| 6539 | + * Verifies whether the URL strings can be parsed. The function assumes | ||
| 6540 | + * that the inputs are valid ASCII or UTF-8 strings. | ||
| 6528 | 6541 | * @see https://url.spec.whatwg.org/#dom-url-canparse | |
| 6529 | 6542 | * @return If URL can be parsed or not. | |
| 6530 | 6543 | */ | |
| 6531 | 6544 | bool can_parse(std::string_view input, | |
| 6532 | 6545 | const std::string_view* base_input = nullptr); | |
| 6533 | 6546 | ||
| 6534 | 6547 | /** | |
| 6535 | - * Computes a href string from a file path. | ||
| 6548 | + * Computes a href string from a file path. The function assumes | ||
| 6549 | + * that the input is a valid ASCII or UTF-8 string. | ||
| 6536 | 6550 | * @return a href string (starts with file:://) | |
| 6537 | 6551 | */ | |
| 6538 | 6552 | std::string href_from_file(std::string_view path); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments