|
1 | | -/* auto-generated on 2025-03-30 13:24:42 -0400. Do not edit! */ |
| 1 | +/* auto-generated on 2025-04-28 12:16:36 -0400. Do not edit! */ |
2 | 2 | /* begin file src/ada.cpp */ |
3 | 3 | #include "ada.h" |
4 | 4 | /* begin file src/checkers.cpp */ |
@@ -56,8 +56,8 @@ ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept { |
56 | 56 | } |
57 | 57 | // We have 0x followed by some characters, we need to check that they are |
58 | 58 | // hexadecimals. |
59 | | - return std::all_of(view.begin() + 2, view.end(), |
60 | | - ada::unicode::is_lowercase_hex); |
| 59 | + view.remove_prefix(2); |
| 60 | + return std::ranges::all_of(view, ada::unicode::is_lowercase_hex); |
61 | 61 | } |
62 | 62 |
|
63 | 63 | // for use with path_signature, we include all characters that need percent |
@@ -10421,6 +10421,8 @@ ADA_POP_DISABLE_WARNINGS |
10421 | 10421 | #include <emmintrin.h> |
10422 | 10422 | #endif |
10423 | 10423 |
|
| 10424 | +#include <ranges> |
| 10425 | + |
10424 | 10426 | namespace ada::unicode { |
10425 | 10427 |
|
10426 | 10428 | constexpr bool is_tabs_or_newline(char c) noexcept { |
@@ -10461,8 +10463,7 @@ ada_really_inline bool has_tabs_or_newline( |
10461 | 10463 | std::string_view user_input) noexcept { |
10462 | 10464 | // first check for short strings in which case we do it naively. |
10463 | 10465 | if (user_input.size() < 16) { // slow path |
10464 | | - return std::any_of(user_input.begin(), user_input.end(), |
10465 | | - is_tabs_or_newline); |
| 10466 | + return std::ranges::any_of(user_input, is_tabs_or_newline); |
10466 | 10467 | } |
10467 | 10468 | // fast path for long strings (expected to be common) |
10468 | 10469 | size_t i = 0; |
@@ -10500,8 +10501,7 @@ ada_really_inline bool has_tabs_or_newline( |
10500 | 10501 | std::string_view user_input) noexcept { |
10501 | 10502 | // first check for short strings in which case we do it naively. |
10502 | 10503 | if (user_input.size() < 16) { // slow path |
10503 | | - return std::any_of(user_input.begin(), user_input.end(), |
10504 | | - is_tabs_or_newline); |
| 10504 | + return std::ranges::any_of(user_input, is_tabs_or_newline); |
10505 | 10505 | } |
10506 | 10506 | // fast path for long strings (expected to be common) |
10507 | 10507 | size_t i = 0; |
@@ -10832,10 +10832,9 @@ bool percent_encode(const std::string_view input, const uint8_t character_set[], |
10832 | 10832 | std::string& out) { |
10833 | 10833 | ada_log("percent_encode ", input, " to output string while ", |
10834 | 10834 | append ? "appending" : "overwriting"); |
10835 | | - auto pointer = |
10836 | | - std::find_if(input.begin(), input.end(), [character_set](const char c) { |
10837 | | - return character_sets::bit_at(character_set, c); |
10838 | | - }); |
| 10835 | + auto pointer = std::ranges::find_if(input, [character_set](const char c) { |
| 10836 | + return character_sets::bit_at(character_set, c); |
| 10837 | + }); |
10839 | 10838 | ada_log("percent_encode done checking, moved to ", |
10840 | 10839 | std::distance(input.begin(), pointer)); |
10841 | 10840 |
|
@@ -11636,15 +11635,20 @@ ada_really_inline void parse_prepared_path(std::string_view input, |
11636 | 11635 | // Note: input cannot be empty, it must at least contain one character ('.') |
11637 | 11636 | // Note: we know that '\' is not present. |
11638 | 11637 | if (input[0] != '.') { |
11639 | | - size_t slashdot = input.find("/."); |
11640 | | - if (slashdot == std::string_view::npos) { // common case |
11641 | | - trivial_path = true; |
11642 | | - } else { // uncommon |
11643 | | - // only three cases matter: /./, /.. or a final / |
11644 | | - trivial_path = |
11645 | | - !(slashdot + 2 == input.size() || input[slashdot + 2] == '.' || |
11646 | | - input[slashdot + 2] == '/'); |
| 11638 | + size_t slashdot = 0; |
| 11639 | + bool dot_is_file = true; |
| 11640 | + for (;;) { |
| 11641 | + slashdot = input.find("/.", slashdot); |
| 11642 | + if (slashdot == std::string_view::npos) { // common case |
| 11643 | + break; |
| 11644 | + } else { // uncommon |
| 11645 | + // only three cases matter: /./, /.. or a final / |
| 11646 | + slashdot += 2; |
| 11647 | + dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' || |
| 11648 | + input[slashdot] == '/'); |
| 11649 | + } |
11647 | 11650 | } |
| 11651 | + trivial_path = dot_is_file; |
11648 | 11652 | } |
11649 | 11653 | } |
11650 | 11654 | if (trivial_path) { |
@@ -11845,15 +11849,15 @@ ada_warn_unused std::string to_string(ada::state state) { |
11845 | 11849 |
|
11846 | 11850 | #include <numeric> |
11847 | 11851 | #include <algorithm> |
| 11852 | +#include <ranges> |
11848 | 11853 | #include <string> |
11849 | 11854 | #include <string_view> |
11850 | 11855 |
|
11851 | 11856 | namespace ada { |
11852 | 11857 |
|
11853 | 11858 | bool url::parse_opaque_host(std::string_view input) { |
11854 | 11859 | ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]"); |
11855 | | - if (std::ranges::any_of(input.begin(), input.end(), |
11856 | | - ada::unicode::is_forbidden_host_code_point)) { |
| 11860 | + if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) { |
11857 | 11861 | return is_valid = false; |
11858 | 11862 | } |
11859 | 11863 |
|
@@ -12720,6 +12724,7 @@ bool url::set_href(const std::string_view input) { |
12720 | 12724 | /* begin file src/parser.cpp */ |
12721 | 12725 |
|
12722 | 12726 | #include <limits> |
| 12727 | +#include <ranges> |
12723 | 12728 |
|
12724 | 12729 |
|
12725 | 12730 | namespace ada::parser { |
@@ -13339,7 +13344,7 @@ result_type parse_url_impl(std::string_view user_input, |
13339 | 13344 | // to optimize it. |
13340 | 13345 | if (view.ends_with(' ')) { |
13341 | 13346 | std::string modified_view = |
13342 | | - std::string(view.begin(), view.end() - 1) + "%20"; |
| 13347 | + std::string(view.substr(0, view.size() - 1)) + "%20"; |
13343 | 13348 | url.update_base_pathname(unicode::percent_encode( |
13344 | 13349 | modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE)); |
13345 | 13350 | } else { |
@@ -13689,6 +13694,7 @@ namespace ada { |
13689 | 13694 | /* end file src/url_components.cpp */ |
13690 | 13695 | /* begin file src/url_aggregator.cpp */ |
13691 | 13696 |
|
| 13697 | +#include <ranges> |
13692 | 13698 | #include <string> |
13693 | 13699 | #include <string_view> |
13694 | 13700 |
|
@@ -13908,7 +13914,7 @@ bool url_aggregator::set_protocol(const std::string_view input) { |
13908 | 13914 |
|
13909 | 13915 | if (pointer != view.end() && *pointer == ':') { |
13910 | 13916 | return parse_scheme_with_colon<true>( |
13911 | | - std::string_view(view.data(), pointer - view.begin() + 1)); |
| 13917 | + view.substr(0, pointer - view.begin() + 1)); |
13912 | 13918 | } |
13913 | 13919 | return false; |
13914 | 13920 | } |
@@ -14170,8 +14176,8 @@ ada_really_inline bool url_aggregator::parse_host(std::string_view input) { |
14170 | 14176 | ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(), |
14171 | 14177 | " bytes]"); |
14172 | 14178 |
|
14173 | | - if (std::any_of(host.value().begin(), host.value().end(), |
14174 | | - ada::unicode::is_forbidden_domain_code_point)) { |
| 14179 | + if (std::ranges::any_of(host.value(), |
| 14180 | + ada::unicode::is_forbidden_domain_code_point)) { |
14175 | 14181 | return is_valid = false; |
14176 | 14182 | } |
14177 | 14183 |
|
@@ -14863,8 +14869,7 @@ bool url_aggregator::parse_opaque_host(std::string_view input) { |
14863 | 14869 | ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]"); |
14864 | 14870 | ADA_ASSERT_TRUE(validate()); |
14865 | 14871 | ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer)); |
14866 | | - if (std::any_of(input.begin(), input.end(), |
14867 | | - ada::unicode::is_forbidden_host_code_point)) { |
| 14872 | + if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) { |
14868 | 14873 | return is_valid = false; |
14869 | 14874 | } |
14870 | 14875 |
|
@@ -15093,15 +15098,20 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) { |
15093 | 15098 | // Note: input cannot be empty, it must at least contain one character ('.') |
15094 | 15099 | // Note: we know that '\' is not present. |
15095 | 15100 | if (input[0] != '.') { |
15096 | | - size_t slashdot = input.find("/."); |
15097 | | - if (slashdot == std::string_view::npos) { // common case |
15098 | | - trivial_path = true; |
15099 | | - } else { // uncommon |
15100 | | - // only three cases matter: /./, /.. or a final / |
15101 | | - trivial_path = |
15102 | | - !(slashdot + 2 == input.size() || input[slashdot + 2] == '.' || |
15103 | | - input[slashdot + 2] == '/'); |
| 15101 | + size_t slashdot = 0; |
| 15102 | + bool dot_is_file = true; |
| 15103 | + for (;;) { |
| 15104 | + slashdot = input.find("/.", slashdot); |
| 15105 | + if (slashdot == std::string_view::npos) { // common case |
| 15106 | + break; |
| 15107 | + } else { // uncommon |
| 15108 | + // only three cases matter: /./, /.. or a final / |
| 15109 | + slashdot += 2; |
| 15110 | + dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' || |
| 15111 | + input[slashdot] == '/'); |
| 15112 | + } |
15104 | 15113 | } |
| 15114 | + trivial_path = dot_is_file; |
15105 | 15115 | } |
15106 | 15116 | } |
15107 | 15117 | if (trivial_path && is_at_path()) { |
|
0 commit comments