Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update ada to 2.2.0 #47678

Merged
merged 2 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 41 additions & 48 deletions deps/ada/ada.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2023-04-17 12:20:41 -0400. Do not edit! */
/* auto-generated on 2023-04-20 18:39:35 -0400. Do not edit! */
/* begin file src/ada.cpp */
#include "ada.h"
/* begin file src/checkers.cpp */
Expand Down Expand Up @@ -10501,18 +10501,18 @@ ada_unused std::string get_state(ada::state s) {
}
}

ada_really_inline std::optional<std::string_view> prune_fragment(
ada_really_inline std::optional<std::string_view> prune_hash(
std::string_view& input) noexcept {
// compiles down to 20--30 instructions including a class to memchr (C
// function). this function should be quite fast.
size_t location_of_first = input.find('#');
if (location_of_first == std::string_view::npos) {
return std::nullopt;
}
std::string_view fragment = input;
fragment.remove_prefix(location_of_first + 1);
std::string_view hash = input;
hash.remove_prefix(location_of_first + 1);
input.remove_suffix(input.size() - location_of_first);
return fragment;
return hash;
}

ada_really_inline bool shorten_path(std::string& path,
Expand All @@ -10523,9 +10523,9 @@ ada_really_inline bool shorten_path(std::string& path,
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized
// Windows drive letter, then return.
if (type == ada::scheme::type::FILE &&
first_delimiter == std::string_view::npos) {
first_delimiter == std::string_view::npos && !path.empty()) {
if (checkers::is_normalized_windows_drive_letter(
std::string_view(path.data() + 1, first_delimiter - 1))) {
helpers::substring(path, 1))) {
return false;
}
}
Expand All @@ -10547,9 +10547,9 @@ ada_really_inline bool shorten_path(std::string_view& path,
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized
// Windows drive letter, then return.
if (type == ada::scheme::type::FILE &&
first_delimiter == std::string_view::npos) {
first_delimiter == std::string_view::npos && !path.empty()) {
if (checkers::is_normalized_windows_drive_letter(
std::string_view(path.data() + 1, first_delimiter - 1))) {
helpers::substring(path, 1))) {
return false;
}
}
Expand Down Expand Up @@ -10998,8 +10998,8 @@ ada_really_inline void strip_trailing_spaces_from_opaque_path(
url_type& url) noexcept {
ada_log("helpers::strip_trailing_spaces_from_opaque_path");
if (!url.has_opaque_path) return;
if (url.base_fragment_has_value()) return;
if (url.base_search_has_value()) return;
if (url.has_hash()) return;
if (url.has_search()) return;

auto path = std::string(url.get_pathname());
while (!path.empty() && path.back() == ' ') {
Expand Down Expand Up @@ -11451,7 +11451,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {

// If url includes credentials or has a non-null port, and buffer is
// "file", then return.
if ((includes_credentials() || port.has_value()) &&
if ((has_credentials() || port.has_value()) &&
parsed_type == ada::scheme::type::FILE) {
return true;
}
Expand Down Expand Up @@ -11496,7 +11496,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {

// If url includes credentials or has a non-null port, and buffer is
// "file", then return.
if ((includes_credentials() || port.has_value()) && _buffer == "file") {
if ((has_credentials() || port.has_value()) && _buffer == "file") {
return true;
}

Expand Down Expand Up @@ -11648,7 +11648,7 @@ std::string url::to_string() const {
answer.append("\t\"protocol\":\"");
helpers::encode_json(get_protocol(), back);
answer.append("\",\n");
if (includes_credentials()) {
if (has_credentials()) {
answer.append("\t\"username\":\"");
helpers::encode_json(username, back);
answer.append("\",\n");
Expand All @@ -11671,16 +11671,16 @@ std::string url::to_string() const {
answer.append("\",\n");
answer.append("\t\"opaque path\":");
answer.append((has_opaque_path ? "true" : "false"));
if (base_search_has_value()) {
if (has_search()) {
answer.append(",\n");
answer.append("\t\"query\":\"");
helpers::encode_json(query.value(), back);
answer.append("\"");
}
if (fragment.has_value()) {
if (hash.has_value()) {
answer.append(",\n");
answer.append("\t\"fragment\":\"");
helpers::encode_json(fragment.value(), back);
answer.append("\t\"hash\":\"");
helpers::encode_json(hash.value(), back);
answer.append("\"");
}
answer.append("\n}");
Expand Down Expand Up @@ -11781,9 +11781,8 @@ namespace ada {
[[nodiscard]] std::string url::get_hash() const noexcept {
// If this’s URL’s fragment is either null or the empty string, then return
// the empty string. Return U+0023 (#), followed by this’s URL’s fragment.
return (!fragment.has_value() || (fragment.value().empty()))
? ""
: "#" + fragment.value();
return (!hash.has_value() || (hash.value().empty())) ? ""
: "#" + hash.value();
}

} // namespace ada
Expand Down Expand Up @@ -11839,7 +11838,7 @@ bool url::set_host_or_hostname(const std::string_view input) {
// empty string, and either url includes credentials or url’s port is
// non-null, return.
else if (host_view.empty() &&
(is_special() || includes_credentials() || port.has_value())) {
(is_special() || has_credentials() || port.has_value())) {
return false;
}

Expand Down Expand Up @@ -11939,16 +11938,16 @@ bool url::set_port(const std::string_view input) {

void url::set_hash(const std::string_view input) {
if (input.empty()) {
fragment = std::nullopt;
hash = std::nullopt;
helpers::strip_trailing_spaces_from_opaque_path(*this);
return;
}

std::string new_value;
new_value = input[0] == '#' ? input.substr(1) : input;
helpers::remove_ascii_tab_or_newline(new_value);
fragment = unicode::percent_encode(
new_value, ada::character_sets::FRAGMENT_PERCENT_ENCODE);
hash = unicode::percent_encode(new_value,
ada::character_sets::FRAGMENT_PERCENT_ENCODE);
return;
}

Expand Down Expand Up @@ -12014,7 +12013,7 @@ bool url::set_href(const std::string_view input) {
port = out->port;
path = out->path;
query = out->query;
fragment = out->fragment;
hash = out->hash;
type = out->type;
non_special_scheme = out->non_special_scheme;
has_opaque_path = out->has_opaque_path;
Expand Down Expand Up @@ -12106,7 +12105,7 @@ result_type parse_url(std::string_view user_input,
helpers::trim_c0_whitespace(url_data);

// Optimization opportunity. Most websites do not have fragment.
std::optional<std::string_view> fragment = helpers::prune_fragment(url_data);
std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
// We add it last so that an implementation like ada::url_aggregator
// can append it last to its internal buffer, thus improving performance.

Expand Down Expand Up @@ -12463,7 +12462,7 @@ result_type parse_url(std::string_view user_input,
// Otherwise, if c is not the EOF code point:
else if (input_position != input_size) {
// Set url’s query to null.
url.clear_base_search();
url.clear_search();
if constexpr (result_type_is_ada_url) {
// Shorten url’s path.
helpers::shorten_path(url.path, url.type);
Expand Down Expand Up @@ -12878,7 +12877,7 @@ result_type parse_url(std::string_view user_input,
// Otherwise, if c is not the EOF code point:
else if (input_position != input_size) {
// Set url’s query to null.
url.clear_base_search();
url.clear_search();

// If the code point substring from pointer to the end of input does
// not start with a Windows drive letter, then shorten url’s path.
Expand All @@ -12895,11 +12894,7 @@ result_type parse_url(std::string_view user_input,
// Otherwise:
else {
// Set url’s path to an empty list.
if constexpr (result_type_is_ada_url) {
url.path.clear();
} else {
url.clear_base_pathname();
}
url.clear_pathname();
url.has_opaque_path = true;
}

Expand Down Expand Up @@ -13091,8 +13086,7 @@ template <bool has_state_override>

// If url includes credentials or has a non-null port, and buffer is
// "file", then return.
if ((includes_credentials() ||
components.port != url_components::omitted) &&
if ((has_credentials() || components.port != url_components::omitted) &&
parsed_type == ada::scheme::type::FILE) {
return true;
}
Expand All @@ -13115,7 +13109,7 @@ template <bool has_state_override>
// If url’s port is url’s scheme’s default port, then set url’s port to
// null.
if (components.port == urls_scheme_port) {
clear_base_port();
clear_port();
}
}
} else { // slow path
Expand All @@ -13135,8 +13129,7 @@ template <bool has_state_override>

// If url includes credentials or has a non-null port, and buffer is
// "file", then return.
if ((includes_credentials() ||
components.port != url_components::omitted) &&
if ((has_credentials() || components.port != url_components::omitted) &&
_buffer == "file") {
return true;
}
Expand All @@ -13158,7 +13151,7 @@ template <bool has_state_override>
// If url’s port is url’s scheme’s default port, then set url’s port to
// null.
if (components.port == urls_scheme_port) {
clear_base_port();
clear_port();
}
}
}
Expand Down Expand Up @@ -13339,7 +13332,7 @@ bool url_aggregator::set_port(const std::string_view input) {
std::string trimmed(input);
helpers::remove_ascii_tab_or_newline(trimmed);
if (trimmed.empty()) {
clear_base_port();
clear_port();
return true;
}
// Input should not start with control characters.
Expand Down Expand Up @@ -13370,7 +13363,7 @@ bool url_aggregator::set_pathname(const std::string_view input) {
if (has_opaque_path) {
return false;
}
clear_base_pathname();
clear_pathname();
parse_path(input);
if (checkers::begins_with(input, "//") && !has_authority() &&
!has_dash_dot()) {
Expand Down Expand Up @@ -13427,7 +13420,7 @@ void url_aggregator::set_search(const std::string_view input) {
ADA_ASSERT_TRUE(validate());
ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
if (input.empty()) {
clear_base_search();
clear_search();
helpers::strip_trailing_spaces_from_opaque_path(*this);
return;
}
Expand Down Expand Up @@ -13623,15 +13616,15 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) {
// empty string, and either url includes credentials or url’s port is
// non-null, return.
else if (host_view.empty() &&
(is_special() || includes_credentials() ||
(is_special() || has_credentials() ||
components.port != url_components::omitted)) {
return false;
}

// Let host be the result of host parsing host_view with url is not special.
if (host_view.empty()) {
if (has_hostname()) {
clear_base_hostname(); // easy!
clear_hostname(); // easy!
} else if (has_dash_dot()) {
add_authority_slashes_if_needed();
delete_dash_dot();
Expand All @@ -13657,7 +13650,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) {

if (new_host.empty()) {
// Set url’s host to the empty string.
clear_base_hostname();
clear_hostname();
} else {
// Let host be the result of host parsing buffer with url is not special.
if (!parse_host(new_host)) {
Expand All @@ -13669,7 +13662,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) {
// If host is "localhost", then set host to the empty string.
if (helpers::substring(buffer, components.host_start,
components.host_end) == "localhost") {
clear_base_hostname();
clear_hostname();
}
}
ADA_ASSERT_TRUE(validate());
Expand Down Expand Up @@ -13836,7 +13829,7 @@ std::string ada::url_aggregator::to_string() const {
helpers::encode_json(get_protocol(), back);
answer.append("\",\n");

if (includes_credentials()) {
if (has_credentials()) {
answer.append("\t\"username\":\"");
helpers::encode_json(get_username(), back);
answer.append("\",\n");
Expand Down
Loading