Skip to content

Commit

Permalink
deps: update ada to 2.6.5
Browse files Browse the repository at this point in the history
PR-URL: #49340
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
nodejs-github-bot committed Sep 30, 2023
1 parent a20a328 commit baf2256
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 52 deletions.
107 changes: 70 additions & 37 deletions deps/ada/ada.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2023-08-26 17:38:28 -0400. Do not edit! */
/* auto-generated on 2023-08-30 11:44:21 -0400. Do not edit! */
/* begin file src/ada.cpp */
#include "ada.h"
/* begin file src/checkers.cpp */
Expand Down Expand Up @@ -116,10 +116,11 @@ ada_really_inline constexpr bool verify_dns_length(

ADA_PUSH_DISABLE_ALL_WARNINGS
/* begin file src/ada_idna.cpp */
/* auto-generated on 2023-05-07 19:12:14 -0400. Do not edit! */
/* auto-generated on 2023-08-29 15:28:19 -0400. Do not edit! */
/* begin file src/idna.cpp */
/* begin file src/unicode_transcoding.cpp */

#include <algorithm>
#include <cstdint>
#include <cstring>

Expand Down Expand Up @@ -226,38 +227,22 @@ size_t utf8_length_from_utf32(const char32_t* buf, size_t len) {
// We are not BOM aware.
const uint32_t* p = reinterpret_cast<const uint32_t*>(buf);
size_t counter{0};
for (size_t i = 0; i < len; i++) {
/** ASCII **/
if (p[i] <= 0x7F) {
counter++;
}
/** two-byte **/
else if (p[i] <= 0x7FF) {
counter += 2;
}
/** three-byte **/
else if (p[i] <= 0xFFFF) {
counter += 3;
}
/** four-bytes **/
else {
counter += 4;
}
for (size_t i = 0; i != len; ++i) {
++counter; // ASCII
counter += static_cast<size_t>(p[i] > 0x7F); // two-byte
counter += static_cast<size_t>(p[i] > 0x7FF); // three-byte
counter += static_cast<size_t>(p[i] > 0xFFFF); // four-bytes
}
return counter;
}

size_t utf32_length_from_utf8(const char* buf, size_t len) {
const int8_t* p = reinterpret_cast<const int8_t*>(buf);
size_t counter{0};
for (size_t i = 0; i < len; i++) {
return std::count_if(p, std::next(p, len), [](int8_t c) {
// -65 is 0b10111111, anything larger in two-complement's
// should start a new code point.
if (p[i] > -65) {
counter++;
}
}
return counter;
return c > -65;
});
}

size_t utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) {
Expand Down Expand Up @@ -9525,14 +9510,14 @@ bool constexpr begins_with(std::u32string_view view,
if (view.size() < prefix.size()) {
return false;
}
return view.substr(0, prefix.size()) == prefix;
return std::equal(prefix.begin(), prefix.end(), view.begin());
}

bool constexpr begins_with(std::string_view view, std::string_view prefix) {
if (view.size() < prefix.size()) {
return false;
}
return view.substr(0, prefix.size()) == prefix;
return std::equal(prefix.begin(), prefix.end(), view.begin());
}

bool constexpr is_ascii(std::u32string_view view) {
Expand Down Expand Up @@ -10144,13 +10129,12 @@ ada_really_inline constexpr bool is_lowercase_hex(const char c) noexcept {
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
}

constexpr static char hex_to_binary_table[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11,
12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15};
unsigned constexpr convert_hex_to_binary(const char c) noexcept {
// this code can be optimized.
if (c <= '9') {
return c - '0';
}
char del = c >= 'a' ? 'a' : 'A';
return 10 + (c - del);
return hex_to_binary_table[c - '0'];
}

std::string percent_decode(const std::string_view input, size_t first_percent) {
Expand All @@ -10159,8 +10143,9 @@ std::string percent_decode(const std::string_view input, size_t first_percent) {
if (first_percent == std::string_view::npos) {
return std::string(input);
}
std::string dest(input.substr(0, first_percent));
std::string dest;
dest.reserve(input.length());
dest.append(input.substr(0, first_percent));
const char* pointer = input.data() + first_percent;
const char* end = input.data() + input.size();
// Optimization opportunity: if the following code gets
Expand Down Expand Up @@ -10197,9 +10182,10 @@ std::string percent_encode(const std::string_view input,
return std::string(input);
}

std::string result(input.substr(0, std::distance(input.begin(), pointer)));
std::string result;
result.reserve(input.length()); // in the worst case, percent encoding might
// produce 3 characters.
result.append(input.substr(0, std::distance(input.begin(), pointer)));

for (; pointer != input.end(); pointer++) {
if (character_sets::bit_at(character_set, *pointer)) {
Expand Down Expand Up @@ -15015,7 +15001,7 @@ ada_string ada_get_protocol(ada_url result) noexcept {
return ada_string_create(out.data(), out.length());
}

uint8_t ada_get_url_host_type(ada_url result) noexcept {
uint8_t ada_get_host_type(ada_url result) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (!r) {
return 0;
Expand Down Expand Up @@ -15092,20 +15078,67 @@ bool ada_set_pathname(ada_url result, const char* input,
return r->set_pathname(std::string_view(input, length));
}

/**
* Update the search/query of the URL.
*
* If a URL has `?` as the search value, passing empty string to this function
* does not remove the attribute. If you need to remove it, please use
* `ada_clear_search` method.
*/
void ada_set_search(ada_url result, const char* input, size_t length) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (r) {
r->set_search(std::string_view(input, length));
}
}

/**
* Update the hash/fragment of the URL.
*
* If a URL has `#` as the hash value, passing empty string to this function
* does not remove the attribute. If you need to remove it, please use
* `ada_clear_hash` method.
*/
void ada_set_hash(ada_url result, const char* input, size_t length) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (r) {
r->set_hash(std::string_view(input, length));
}
}

void ada_clear_port(ada_url result) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (r) {
r->clear_port();
}
}

/**
* Removes the hash of the URL.
*
* Despite `ada_set_hash` method, this function allows the complete
* removal of the hash attribute, even if it has a value of `#`.
*/
void ada_clear_hash(ada_url result) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (r) {
r->clear_hash();
}
}

/**
* Removes the search of the URL.
*
* Despite `ada_set_search` method, this function allows the complete
* removal of the search attribute, even if it has a value of `?`.
*/
void ada_clear_search(ada_url result) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (r) {
r->clear_search();
}
}

bool ada_has_credentials(ada_url result) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (!r) {
Expand Down
26 changes: 15 additions & 11 deletions deps/ada/ada.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2023-08-26 17:38:28 -0400. Do not edit! */
/* auto-generated on 2023-08-30 11:44:21 -0400. Do not edit! */
/* begin file include/ada.h */
/**
* @file ada.h
Expand All @@ -8,7 +8,7 @@
#define ADA_H

/* begin file include/ada/ada_idna.h */
/* auto-generated on 2023-05-07 19:12:14 -0400. Do not edit! */
/* auto-generated on 2023-08-29 15:28:19 -0400. Do not edit! */
/* begin file include/idna.h */
#ifndef ADA_IDNA_H
#define ADA_IDNA_H
Expand Down Expand Up @@ -4584,9 +4584,10 @@ ada_really_inline constexpr bool is_single_dot_path_segment(
ada_really_inline constexpr bool is_lowercase_hex(const char c) noexcept;

/**
* @details Convert hex to binary.
* @details Convert hex to binary. Caller is responsible to ensure that
* the parameter is an hexadecimal digit (0-9, A-F, a-f).
*/
unsigned constexpr convert_hex_to_binary(char c) noexcept;
ada_really_inline unsigned constexpr convert_hex_to_binary(char c) noexcept;

/**
* first_percent should be = input.find('%')
Expand Down Expand Up @@ -4840,6 +4841,10 @@ struct url_aggregator : url_base {
/** @return true if the URL has a search component */
[[nodiscard]] inline bool has_search() const noexcept override;

inline void clear_port();
inline void clear_hash();
inline void clear_search() override;

private:
friend ada::url_aggregator ada::parser::parse_url<ada::url_aggregator>(
std::string_view, const ada::url_aggregator *);
Expand Down Expand Up @@ -4914,12 +4919,9 @@ struct url_aggregator : url_base {
inline void update_base_port(uint32_t input);
inline void append_base_pathname(const std::string_view input);
inline uint32_t retrieve_base_port() const;
inline void clear_port();
inline void clear_hostname();
inline void clear_hash();
inline void clear_pathname() override;
inline void clear_search() override;
inline void clear_password();
inline void clear_pathname() override;
inline bool has_dash_dot() const noexcept;
void delete_dash_dot();
inline void consume_prepared_path(std::string_view input);
Expand Down Expand Up @@ -6448,7 +6450,9 @@ inline void url_aggregator::clear_hostname() {
" with " + components.to_string() + "\n" + to_diagram());
#endif
ADA_ASSERT_TRUE(has_authority());
ADA_ASSERT_TRUE(has_empty_hostname());
ADA_ASSERT_EQUAL(has_empty_hostname(), true,
"hostname should have been cleared on buffer=" + buffer +
" with " + components.to_string() + "\n" + to_diagram());
ADA_ASSERT_TRUE(validate());
}

Expand Down Expand Up @@ -6922,14 +6926,14 @@ inline void url_search_params::sort() {
#ifndef ADA_ADA_VERSION_H
#define ADA_ADA_VERSION_H

#define ADA_VERSION "2.6.3"
#define ADA_VERSION "2.6.5"

namespace ada {

enum {
ADA_VERSION_MAJOR = 2,
ADA_VERSION_MINOR = 6,
ADA_VERSION_REVISION = 3,
ADA_VERSION_REVISION = 5,
};

} // namespace ada
Expand Down
7 changes: 6 additions & 1 deletion deps/ada/ada_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ada_string ada_get_hostname(ada_url result);
ada_string ada_get_pathname(ada_url result);
ada_string ada_get_search(ada_url result);
ada_string ada_get_protocol(ada_url result);
uint8_t ada_get_url_host_type(ada_url result);
uint8_t ada_get_host_type(ada_url result);

// url_aggregator setters
// if ada_is_valid(result)) is false, the setters have no effect
Expand All @@ -84,6 +84,11 @@ bool ada_set_pathname(ada_url result, const char* input, size_t length);
void ada_set_search(ada_url result, const char* input, size_t length);
void ada_set_hash(ada_url result, const char* input, size_t length);

// url_aggregator clear methods
void ada_clear_port(ada_url result);
void ada_clear_hash(ada_url result);
void ada_clear_search(ada_url result);

// url_aggregator functions
// if ada_is_valid(result) is false, functions below will return false
bool ada_has_credentials(ada_url result);
Expand Down
6 changes: 3 additions & 3 deletions doc/contributing/maintaining/maintaining-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All dependencies are located within the `deps` directory.
This a list of all the dependencies:

* [acorn 8.10.0][]
* [ada 2.6.3][]
* [ada 2.6.5][]
* [base64 0.5.0][]
* [brotli 1.0.9][]
* [c-ares 1.19.0][]
Expand Down Expand Up @@ -150,7 +150,7 @@ The [acorn](https://github.com/acornjs/acorn) dependency is a JavaScript parser.
[acorn-walk](https://github.com/acornjs/acorn/tree/master/acorn-walk) is
an abstract syntax tree walker for the ESTree format.

### ada 2.6.3
### ada 2.6.5

The [ada](https://github.com/ada-url/ada) dependency is a
fast and spec-compliant URL parser written in C++.
Expand Down Expand Up @@ -319,7 +319,7 @@ it comes from the Chromium team's zlib fork which incorporated
performance improvements not currently available in standard zlib.

[acorn 8.10.0]: #acorn-8100
[ada 2.6.3]: #ada-263
[ada 2.6.5]: #ada-265
[base64 0.5.0]: #base64-050
[brotli 1.0.9]: #brotli-109
[c-ares 1.19.0]: #c-ares-1190
Expand Down

0 comments on commit baf2256

Please sign in to comment.