| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - /* auto-generated on 2023-04-17 12:20:41 -0400. Do not edit! */ | ||
| 1 | + /* auto-generated on 2023-04-20 18:39:35 -0400. Do not edit! */ | ||
| 2 | 2 | /* begin file src/ada.cpp */ | |
| 3 | 3 | #include "ada.h" | |
| 4 | 4 | /* begin file src/checkers.cpp */ | |
@@ -10501,18 +10501,18 @@ ada_unused std::string get_state(ada::state s) { | |||
| 10501 | 10501 | } | |
| 10502 | 10502 | } | |
| 10503 | 10503 | ||
| 10504 | - ada_really_inline std::optional<std::string_view> prune_fragment( | ||
| 10504 | + ada_really_inline std::optional<std::string_view> prune_hash( | ||
| 10505 | 10505 | std::string_view& input) noexcept { | |
| 10506 | 10506 | // compiles down to 20--30 instructions including a class to memchr (C | |
| 10507 | 10507 | // function). this function should be quite fast. | |
| 10508 | 10508 | size_t location_of_first = input.find('#'); | |
| 10509 | 10509 | if (location_of_first == std::string_view::npos) { | |
| 10510 | 10510 | return std::nullopt; | |
| 10511 | 10511 | } | |
| 10512 | - std::string_view fragment = input; | ||
| 10513 | - fragment.remove_prefix(location_of_first + 1); | ||
| 10512 | + std::string_view hash = input; | ||
| 10513 | + hash.remove_prefix(location_of_first + 1); | ||
| 10514 | 10514 | input.remove_suffix(input.size() - location_of_first); | |
| 10515 | - return fragment; | ||
| 10515 | + return hash; | ||
| 10516 | 10516 | } | |
| 10517 | 10517 | ||
| 10518 | 10518 | ada_really_inline bool shorten_path(std::string& path, | |
@@ -10523,9 +10523,9 @@ ada_really_inline bool shorten_path(std::string& path, | |||
| 10523 | 10523 | // If url’s scheme is "file", path’s size is 1, and path[0] is a normalized | |
| 10524 | 10524 | // Windows drive letter, then return. | |
| 10525 | 10525 | if (type == ada::scheme::type::FILE && | |
| 10526 | - first_delimiter == std::string_view::npos) { | ||
| 10526 | + first_delimiter == std::string_view::npos && !path.empty()) { | ||
| 10527 | 10527 | if (checkers::is_normalized_windows_drive_letter( | |
| 10528 | - std::string_view(path.data() + 1, first_delimiter - 1))) { | ||
| 10528 | + helpers::substring(path, 1))) { | ||
| 10529 | 10529 | return false; | |
| 10530 | 10530 | } | |
| 10531 | 10531 | } | |
@@ -10547,9 +10547,9 @@ ada_really_inline bool shorten_path(std::string_view& path, | |||
| 10547 | 10547 | // If url’s scheme is "file", path’s size is 1, and path[0] is a normalized | |
| 10548 | 10548 | // Windows drive letter, then return. | |
| 10549 | 10549 | if (type == ada::scheme::type::FILE && | |
| 10550 | - first_delimiter == std::string_view::npos) { | ||
| 10550 | + first_delimiter == std::string_view::npos && !path.empty()) { | ||
| 10551 | 10551 | if (checkers::is_normalized_windows_drive_letter( | |
| 10552 | - std::string_view(path.data() + 1, first_delimiter - 1))) { | ||
| 10552 | + helpers::substring(path, 1))) { | ||
| 10553 | 10553 | return false; | |
| 10554 | 10554 | } | |
| 10555 | 10555 | } | |
@@ -10998,8 +10998,8 @@ ada_really_inline void strip_trailing_spaces_from_opaque_path( | |||
| 10998 | 10998 | url_type& url) noexcept { | |
| 10999 | 10999 | ada_log("helpers::strip_trailing_spaces_from_opaque_path"); | |
| 11000 | 11000 | if (!url.has_opaque_path) return; | |
| 11001 | - if (url.base_fragment_has_value()) return; | ||
| 11002 | - if (url.base_search_has_value()) return; | ||
| 11001 | + if (url.has_hash()) return; | ||
| 11002 | + if (url.has_search()) return; | ||
| 11003 | 11003 | ||
| 11004 | 11004 | auto path = std::string(url.get_pathname()); | |
| 11005 | 11005 | while (!path.empty() && path.back() == ' ') { | |
@@ -11451,7 +11451,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) { | |||
| 11451 | 11451 | ||
| 11452 | 11452 | // If url includes credentials or has a non-null port, and buffer is | |
| 11453 | 11453 | // "file", then return. | |
| 11454 | - if ((includes_credentials() || port.has_value()) && | ||
| 11454 | + if ((has_credentials() || port.has_value()) && | ||
| 11455 | 11455 | parsed_type == ada::scheme::type::FILE) { | |
| 11456 | 11456 | return true; | |
| 11457 | 11457 | } | |
@@ -11496,7 +11496,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) { | |||
| 11496 | 11496 | ||
| 11497 | 11497 | // If url includes credentials or has a non-null port, and buffer is | |
| 11498 | 11498 | // "file", then return. | |
| 11499 | - if ((includes_credentials() || port.has_value()) && _buffer == "file") { | ||
| 11499 | + if ((has_credentials() || port.has_value()) && _buffer == "file") { | ||
| 11500 | 11500 | return true; | |
| 11501 | 11501 | } | |
| 11502 | 11502 | ||
@@ -11648,7 +11648,7 @@ std::string url::to_string() const { | |||
| 11648 | 11648 | answer.append("\t\"protocol\":\""); | |
| 11649 | 11649 | helpers::encode_json(get_protocol(), back); | |
| 11650 | 11650 | answer.append("\",\n"); | |
| 11651 | - if (includes_credentials()) { | ||
| 11651 | + if (has_credentials()) { | ||
| 11652 | 11652 | answer.append("\t\"username\":\""); | |
| 11653 | 11653 | helpers::encode_json(username, back); | |
| 11654 | 11654 | answer.append("\",\n"); | |
@@ -11671,16 +11671,16 @@ std::string url::to_string() const { | |||
| 11671 | 11671 | answer.append("\",\n"); | |
| 11672 | 11672 | answer.append("\t\"opaque path\":"); | |
| 11673 | 11673 | answer.append((has_opaque_path ? "true" : "false")); | |
| 11674 | - if (base_search_has_value()) { | ||
| 11674 | + if (has_search()) { | ||
| 11675 | 11675 | answer.append(",\n"); | |
| 11676 | 11676 | answer.append("\t\"query\":\""); | |
| 11677 | 11677 | helpers::encode_json(query.value(), back); | |
| 11678 | 11678 | answer.append("\""); | |
| 11679 | 11679 | } | |
| 11680 | - if (fragment.has_value()) { | ||
| 11680 | + if (hash.has_value()) { | ||
| 11681 | 11681 | answer.append(",\n"); | |
| 11682 | - answer.append("\t\"fragment\":\""); | ||
| 11683 | - helpers::encode_json(fragment.value(), back); | ||
| 11682 | + answer.append("\t\"hash\":\""); | ||
| 11683 | + helpers::encode_json(hash.value(), back); | ||
| 11684 | 11684 | answer.append("\""); | |
| 11685 | 11685 | } | |
| 11686 | 11686 | answer.append("\n}"); | |
@@ -11781,9 +11781,8 @@ namespace ada { | |||
| 11781 | 11781 | [[nodiscard]] std::string url::get_hash() const noexcept { | |
| 11782 | 11782 | // If this’s URL’s fragment is either null or the empty string, then return | |
| 11783 | 11783 | // the empty string. Return U+0023 (#), followed by this’s URL’s fragment. | |
| 11784 | - return (!fragment.has_value() || (fragment.value().empty())) | ||
| 11785 | - ? "" | ||
| 11786 | - : "#" + fragment.value(); | ||
| 11784 | + return (!hash.has_value() || (hash.value().empty())) ? "" | ||
| 11785 | + : "#" + hash.value(); | ||
| 11787 | 11786 | } | |
| 11788 | 11787 | ||
| 11789 | 11788 | } // namespace ada | |
@@ -11839,7 +11838,7 @@ bool url::set_host_or_hostname(const std::string_view input) { | |||
| 11839 | 11838 | // empty string, and either url includes credentials or url’s port is | |
| 11840 | 11839 | // non-null, return. | |
| 11841 | 11840 | else if (host_view.empty() && | |
| 11842 | - (is_special() || includes_credentials() || port.has_value())) { | ||
| 11841 | + (is_special() || has_credentials() || port.has_value())) { | ||
| 11843 | 11842 | return false; | |
| 11844 | 11843 | } | |
| 11845 | 11844 | ||
@@ -11939,16 +11938,16 @@ bool url::set_port(const std::string_view input) { | |||
| 11939 | 11938 | ||
| 11940 | 11939 | void url::set_hash(const std::string_view input) { | |
| 11941 | 11940 | if (input.empty()) { | |
| 11942 | - fragment = std::nullopt; | ||
| 11941 | + hash = std::nullopt; | ||
| 11943 | 11942 | helpers::strip_trailing_spaces_from_opaque_path(*this); | |
| 11944 | 11943 | return; | |
| 11945 | 11944 | } | |
| 11946 | 11945 | ||
| 11947 | 11946 | std::string new_value; | |
| 11948 | 11947 | new_value = input[0] == '#' ? input.substr(1) : input; | |
| 11949 | 11948 | helpers::remove_ascii_tab_or_newline(new_value); | |
| 11950 | - fragment = unicode::percent_encode( | ||
| 11951 | - new_value, ada::character_sets::FRAGMENT_PERCENT_ENCODE); | ||
| 11949 | + hash = unicode::percent_encode(new_value, | ||
| 11950 | + ada::character_sets::FRAGMENT_PERCENT_ENCODE); | ||
| 11952 | 11951 | return; | |
| 11953 | 11952 | } | |
| 11954 | 11953 | ||
@@ -12014,7 +12013,7 @@ bool url::set_href(const std::string_view input) { | |||
| 12014 | 12013 | port = out->port; | |
| 12015 | 12014 | path = out->path; | |
| 12016 | 12015 | query = out->query; | |
| 12017 | - fragment = out->fragment; | ||
| 12016 | + hash = out->hash; | ||
| 12018 | 12017 | type = out->type; | |
| 12019 | 12018 | non_special_scheme = out->non_special_scheme; | |
| 12020 | 12019 | has_opaque_path = out->has_opaque_path; | |
@@ -12106,7 +12105,7 @@ result_type parse_url(std::string_view user_input, | |||
| 12106 | 12105 | helpers::trim_c0_whitespace(url_data); | |
| 12107 | 12106 | ||
| 12108 | 12107 | // Optimization opportunity. Most websites do not have fragment. | |
| 12109 | - std::optional<std::string_view> fragment = helpers::prune_fragment(url_data); | ||
| 12108 | + std::optional<std::string_view> fragment = helpers::prune_hash(url_data); | ||
| 12110 | 12109 | // We add it last so that an implementation like ada::url_aggregator | |
| 12111 | 12110 | // can append it last to its internal buffer, thus improving performance. | |
| 12112 | 12111 | ||
@@ -12463,7 +12462,7 @@ result_type parse_url(std::string_view user_input, | |||
| 12463 | 12462 | // Otherwise, if c is not the EOF code point: | |
| 12464 | 12463 | else if (input_position != input_size) { | |
| 12465 | 12464 | // Set url’s query to null. | |
| 12466 | - url.clear_base_search(); | ||
| 12465 | + url.clear_search(); | ||
| 12467 | 12466 | if constexpr (result_type_is_ada_url) { | |
| 12468 | 12467 | // Shorten url’s path. | |
| 12469 | 12468 | helpers::shorten_path(url.path, url.type); | |
@@ -12878,7 +12877,7 @@ result_type parse_url(std::string_view user_input, | |||
| 12878 | 12877 | // Otherwise, if c is not the EOF code point: | |
| 12879 | 12878 | else if (input_position != input_size) { | |
| 12880 | 12879 | // Set url’s query to null. | |
| 12881 | - url.clear_base_search(); | ||
| 12880 | + url.clear_search(); | ||
| 12882 | 12881 | ||
| 12883 | 12882 | // If the code point substring from pointer to the end of input does | |
| 12884 | 12883 | // not start with a Windows drive letter, then shorten url’s path. | |
@@ -12895,11 +12894,7 @@ result_type parse_url(std::string_view user_input, | |||
| 12895 | 12894 | // Otherwise: | |
| 12896 | 12895 | else { | |
| 12897 | 12896 | // Set url’s path to an empty list. | |
| 12898 | - if constexpr (result_type_is_ada_url) { | ||
| 12899 | - url.path.clear(); | ||
| 12900 | - } else { | ||
| 12901 | - url.clear_base_pathname(); | ||
| 12902 | - } | ||
| 12897 | + url.clear_pathname(); | ||
| 12903 | 12898 | url.has_opaque_path = true; | |
| 12904 | 12899 | } | |
| 12905 | 12900 | ||
@@ -13091,8 +13086,7 @@ template <bool has_state_override> | |||
| 13091 | 13086 | ||
| 13092 | 13087 | // If url includes credentials or has a non-null port, and buffer is | |
| 13093 | 13088 | // "file", then return. | |
| 13094 | - if ((includes_credentials() || | ||
| 13095 | - components.port != url_components::omitted) && | ||
| 13089 | + if ((has_credentials() || components.port != url_components::omitted) && | ||
| 13096 | 13090 | parsed_type == ada::scheme::type::FILE) { | |
| 13097 | 13091 | return true; | |
| 13098 | 13092 | } | |
@@ -13115,7 +13109,7 @@ template <bool has_state_override> | |||
| 13115 | 13109 | // If url’s port is url’s scheme’s default port, then set url’s port to | |
| 13116 | 13110 | // null. | |
| 13117 | 13111 | if (components.port == urls_scheme_port) { | |
| 13118 | - clear_base_port(); | ||
| 13112 | + clear_port(); | ||
| 13119 | 13113 | } | |
| 13120 | 13114 | } | |
| 13121 | 13115 | } else { // slow path | |
@@ -13135,8 +13129,7 @@ template <bool has_state_override> | |||
| 13135 | 13129 | ||
| 13136 | 13130 | // If url includes credentials or has a non-null port, and buffer is | |
| 13137 | 13131 | // "file", then return. | |
| 13138 | - if ((includes_credentials() || | ||
| 13139 | - components.port != url_components::omitted) && | ||
| 13132 | + if ((has_credentials() || components.port != url_components::omitted) && | ||
| 13140 | 13133 | _buffer == "file") { | |
| 13141 | 13134 | return true; | |
| 13142 | 13135 | } | |
@@ -13158,7 +13151,7 @@ template <bool has_state_override> | |||
| 13158 | 13151 | // If url’s port is url’s scheme’s default port, then set url’s port to | |
| 13159 | 13152 | // null. | |
| 13160 | 13153 | if (components.port == urls_scheme_port) { | |
| 13161 | - clear_base_port(); | ||
| 13154 | + clear_port(); | ||
| 13162 | 13155 | } | |
| 13163 | 13156 | } | |
| 13164 | 13157 | } | |
@@ -13339,7 +13332,7 @@ bool url_aggregator::set_port(const std::string_view input) { | |||
| 13339 | 13332 | std::string trimmed(input); | |
| 13340 | 13333 | helpers::remove_ascii_tab_or_newline(trimmed); | |
| 13341 | 13334 | if (trimmed.empty()) { | |
| 13342 | - clear_base_port(); | ||
| 13335 | + clear_port(); | ||
| 13343 | 13336 | return true; | |
| 13344 | 13337 | } | |
| 13345 | 13338 | // Input should not start with control characters. | |
@@ -13370,7 +13363,7 @@ bool url_aggregator::set_pathname(const std::string_view input) { | |||
| 13370 | 13363 | if (has_opaque_path) { | |
| 13371 | 13364 | return false; | |
| 13372 | 13365 | } | |
| 13373 | - clear_base_pathname(); | ||
| 13366 | + clear_pathname(); | ||
| 13374 | 13367 | parse_path(input); | |
| 13375 | 13368 | if (checkers::begins_with(input, "//") && !has_authority() && | |
| 13376 | 13369 | !has_dash_dot()) { | |
@@ -13427,7 +13420,7 @@ void url_aggregator::set_search(const std::string_view input) { | |||
| 13427 | 13420 | ADA_ASSERT_TRUE(validate()); | |
| 13428 | 13421 | ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer)); | |
| 13429 | 13422 | if (input.empty()) { | |
| 13430 | - clear_base_search(); | ||
| 13423 | + clear_search(); | ||
| 13431 | 13424 | helpers::strip_trailing_spaces_from_opaque_path(*this); | |
| 13432 | 13425 | return; | |
| 13433 | 13426 | } | |
@@ -13623,15 +13616,15 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) { | |||
| 13623 | 13616 | // empty string, and either url includes credentials or url’s port is | |
| 13624 | 13617 | // non-null, return. | |
| 13625 | 13618 | else if (host_view.empty() && | |
| 13626 | - (is_special() || includes_credentials() || | ||
| 13619 | + (is_special() || has_credentials() || | ||
| 13627 | 13620 | components.port != url_components::omitted)) { | |
| 13628 | 13621 | return false; | |
| 13629 | 13622 | } | |
| 13630 | 13623 | ||
| 13631 | 13624 | // Let host be the result of host parsing host_view with url is not special. | |
| 13632 | 13625 | if (host_view.empty()) { | |
| 13633 | 13626 | if (has_hostname()) { | |
| 13634 | - clear_base_hostname(); // easy! | ||
| 13627 | + clear_hostname(); // easy! | ||
| 13635 | 13628 | } else if (has_dash_dot()) { | |
| 13636 | 13629 | add_authority_slashes_if_needed(); | |
| 13637 | 13630 | delete_dash_dot(); | |
@@ -13657,7 +13650,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) { | |||
| 13657 | 13650 | ||
| 13658 | 13651 | if (new_host.empty()) { | |
| 13659 | 13652 | // Set url’s host to the empty string. | |
| 13660 | - clear_base_hostname(); | ||
| 13653 | + clear_hostname(); | ||
| 13661 | 13654 | } else { | |
| 13662 | 13655 | // Let host be the result of host parsing buffer with url is not special. | |
| 13663 | 13656 | if (!parse_host(new_host)) { | |
@@ -13669,7 +13662,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) { | |||
| 13669 | 13662 | // If host is "localhost", then set host to the empty string. | |
| 13670 | 13663 | if (helpers::substring(buffer, components.host_start, | |
| 13671 | 13664 | components.host_end) == "localhost") { | |
| 13672 | - clear_base_hostname(); | ||
| 13665 | + clear_hostname(); | ||
| 13673 | 13666 | } | |
| 13674 | 13667 | } | |
| 13675 | 13668 | ADA_ASSERT_TRUE(validate()); | |
@@ -13836,7 +13829,7 @@ std::string ada::url_aggregator::to_string() const { | |||
| 13836 | 13829 | helpers::encode_json(get_protocol(), back); | |
| 13837 | 13830 | answer.append("\",\n"); | |
| 13838 | 13831 | ||
| 13839 | - if (includes_credentials()) { | ||
| 13832 | + if (has_credentials()) { | ||
| 13840 | 13833 | answer.append("\t\"username\":\""); | |
| 13841 | 13834 | helpers::encode_json(get_username(), back); | |
| 13842 | 13835 | answer.append("\",\n"); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments