Skip to content

Commit 31a4e97

Browse files
nodejs-github-bottargos
authored andcommitted
deps: update ada to 2.6.5
PR-URL: #49340 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 2ca867f commit 31a4e97

File tree

4 files changed

+94
-52
lines changed

4 files changed

+94
-52
lines changed

deps/ada/ada.cpp

+70-37
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2023-08-26 17:38:28 -0400. Do not edit! */
1+
/* auto-generated on 2023-08-30 11:44:21 -0400. Do not edit! */
22
/* begin file src/ada.cpp */
33
#include "ada.h"
44
/* begin file src/checkers.cpp */
@@ -116,10 +116,11 @@ ada_really_inline constexpr bool verify_dns_length(
116116

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

123+
#include <algorithm>
123124
#include <cstdint>
124125
#include <cstring>
125126

@@ -226,38 +227,22 @@ size_t utf8_length_from_utf32(const char32_t* buf, size_t len) {
226227
// We are not BOM aware.
227228
const uint32_t* p = reinterpret_cast<const uint32_t*>(buf);
228229
size_t counter{0};
229-
for (size_t i = 0; i < len; i++) {
230-
/** ASCII **/
231-
if (p[i] <= 0x7F) {
232-
counter++;
233-
}
234-
/** two-byte **/
235-
else if (p[i] <= 0x7FF) {
236-
counter += 2;
237-
}
238-
/** three-byte **/
239-
else if (p[i] <= 0xFFFF) {
240-
counter += 3;
241-
}
242-
/** four-bytes **/
243-
else {
244-
counter += 4;
245-
}
230+
for (size_t i = 0; i != len; ++i) {
231+
++counter; // ASCII
232+
counter += static_cast<size_t>(p[i] > 0x7F); // two-byte
233+
counter += static_cast<size_t>(p[i] > 0x7FF); // three-byte
234+
counter += static_cast<size_t>(p[i] > 0xFFFF); // four-bytes
246235
}
247236
return counter;
248237
}
249238

250239
size_t utf32_length_from_utf8(const char* buf, size_t len) {
251240
const int8_t* p = reinterpret_cast<const int8_t*>(buf);
252-
size_t counter{0};
253-
for (size_t i = 0; i < len; i++) {
241+
return std::count_if(p, std::next(p, len), [](int8_t c) {
254242
// -65 is 0b10111111, anything larger in two-complement's
255243
// should start a new code point.
256-
if (p[i] > -65) {
257-
counter++;
258-
}
259-
}
260-
return counter;
244+
return c > -65;
245+
});
261246
}
262247

263248
size_t utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output) {
@@ -9525,14 +9510,14 @@ bool constexpr begins_with(std::u32string_view view,
95259510
if (view.size() < prefix.size()) {
95269511
return false;
95279512
}
9528-
return view.substr(0, prefix.size()) == prefix;
9513+
return std::equal(prefix.begin(), prefix.end(), view.begin());
95299514
}
95309515

95319516
bool constexpr begins_with(std::string_view view, std::string_view prefix) {
95329517
if (view.size() < prefix.size()) {
95339518
return false;
95349519
}
9535-
return view.substr(0, prefix.size()) == prefix;
9520+
return std::equal(prefix.begin(), prefix.end(), view.begin());
95369521
}
95379522

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

10132+
constexpr static char hex_to_binary_table[] = {
10133+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11,
10134+
12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10135+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15};
1014710136
unsigned constexpr convert_hex_to_binary(const char c) noexcept {
10148-
// this code can be optimized.
10149-
if (c <= '9') {
10150-
return c - '0';
10151-
}
10152-
char del = c >= 'a' ? 'a' : 'A';
10153-
return 10 + (c - del);
10137+
return hex_to_binary_table[c - '0'];
1015410138
}
1015510139

1015610140
std::string percent_decode(const std::string_view input, size_t first_percent) {
@@ -10159,8 +10143,9 @@ std::string percent_decode(const std::string_view input, size_t first_percent) {
1015910143
if (first_percent == std::string_view::npos) {
1016010144
return std::string(input);
1016110145
}
10162-
std::string dest(input.substr(0, first_percent));
10146+
std::string dest;
1016310147
dest.reserve(input.length());
10148+
dest.append(input.substr(0, first_percent));
1016410149
const char* pointer = input.data() + first_percent;
1016510150
const char* end = input.data() + input.size();
1016610151
// Optimization opportunity: if the following code gets
@@ -10197,9 +10182,10 @@ std::string percent_encode(const std::string_view input,
1019710182
return std::string(input);
1019810183
}
1019910184

10200-
std::string result(input.substr(0, std::distance(input.begin(), pointer)));
10185+
std::string result;
1020110186
result.reserve(input.length()); // in the worst case, percent encoding might
1020210187
// produce 3 characters.
10188+
result.append(input.substr(0, std::distance(input.begin(), pointer)));
1020310189

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

15018-
uint8_t ada_get_url_host_type(ada_url result) noexcept {
15004+
uint8_t ada_get_host_type(ada_url result) noexcept {
1501915005
ada::result<ada::url_aggregator>& r = get_instance(result);
1502015006
if (!r) {
1502115007
return 0;
@@ -15092,20 +15078,67 @@ bool ada_set_pathname(ada_url result, const char* input,
1509215078
return r->set_pathname(std::string_view(input, length));
1509315079
}
1509415080

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

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

15109+
void ada_clear_port(ada_url result) noexcept {
15110+
ada::result<ada::url_aggregator>& r = get_instance(result);
15111+
if (r) {
15112+
r->clear_port();
15113+
}
15114+
}
15115+
15116+
/**
15117+
* Removes the hash of the URL.
15118+
*
15119+
* Despite `ada_set_hash` method, this function allows the complete
15120+
* removal of the hash attribute, even if it has a value of `#`.
15121+
*/
15122+
void ada_clear_hash(ada_url result) noexcept {
15123+
ada::result<ada::url_aggregator>& r = get_instance(result);
15124+
if (r) {
15125+
r->clear_hash();
15126+
}
15127+
}
15128+
15129+
/**
15130+
* Removes the search of the URL.
15131+
*
15132+
* Despite `ada_set_search` method, this function allows the complete
15133+
* removal of the search attribute, even if it has a value of `?`.
15134+
*/
15135+
void ada_clear_search(ada_url result) noexcept {
15136+
ada::result<ada::url_aggregator>& r = get_instance(result);
15137+
if (r) {
15138+
r->clear_search();
15139+
}
15140+
}
15141+
1510915142
bool ada_has_credentials(ada_url result) noexcept {
1511015143
ada::result<ada::url_aggregator>& r = get_instance(result);
1511115144
if (!r) {

deps/ada/ada.h

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2023-08-26 17:38:28 -0400. Do not edit! */
1+
/* auto-generated on 2023-08-30 11:44:21 -0400. Do not edit! */
22
/* begin file include/ada.h */
33
/**
44
* @file ada.h
@@ -8,7 +8,7 @@
88
#define ADA_H
99

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

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

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

4844+
inline void clear_port();
4845+
inline void clear_hash();
4846+
inline void clear_search() override;
4847+
48434848
private:
48444849
friend ada::url_aggregator ada::parser::parse_url<ada::url_aggregator>(
48454850
std::string_view, const ada::url_aggregator *);
@@ -4914,12 +4919,9 @@ struct url_aggregator : url_base {
49144919
inline void update_base_port(uint32_t input);
49154920
inline void append_base_pathname(const std::string_view input);
49164921
inline uint32_t retrieve_base_port() const;
4917-
inline void clear_port();
49184922
inline void clear_hostname();
4919-
inline void clear_hash();
4920-
inline void clear_pathname() override;
4921-
inline void clear_search() override;
49224923
inline void clear_password();
4924+
inline void clear_pathname() override;
49234925
inline bool has_dash_dot() const noexcept;
49244926
void delete_dash_dot();
49254927
inline void consume_prepared_path(std::string_view input);
@@ -6448,7 +6450,9 @@ inline void url_aggregator::clear_hostname() {
64486450
" with " + components.to_string() + "\n" + to_diagram());
64496451
#endif
64506452
ADA_ASSERT_TRUE(has_authority());
6451-
ADA_ASSERT_TRUE(has_empty_hostname());
6453+
ADA_ASSERT_EQUAL(has_empty_hostname(), true,
6454+
"hostname should have been cleared on buffer=" + buffer +
6455+
" with " + components.to_string() + "\n" + to_diagram());
64526456
ADA_ASSERT_TRUE(validate());
64536457
}
64546458

@@ -6922,14 +6926,14 @@ inline void url_search_params::sort() {
69226926
#ifndef ADA_ADA_VERSION_H
69236927
#define ADA_ADA_VERSION_H
69246928

6925-
#define ADA_VERSION "2.6.3"
6929+
#define ADA_VERSION "2.6.5"
69266930

69276931
namespace ada {
69286932

69296933
enum {
69306934
ADA_VERSION_MAJOR = 2,
69316935
ADA_VERSION_MINOR = 6,
6932-
ADA_VERSION_REVISION = 3,
6936+
ADA_VERSION_REVISION = 5,
69336937
};
69346938

69356939
} // namespace ada

deps/ada/ada_c.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ada_string ada_get_hostname(ada_url result);
6868
ada_string ada_get_pathname(ada_url result);
6969
ada_string ada_get_search(ada_url result);
7070
ada_string ada_get_protocol(ada_url result);
71-
uint8_t ada_get_url_host_type(ada_url result);
71+
uint8_t ada_get_host_type(ada_url result);
7272

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

87+
// url_aggregator clear methods
88+
void ada_clear_port(ada_url result);
89+
void ada_clear_hash(ada_url result);
90+
void ada_clear_search(ada_url result);
91+
8792
// url_aggregator functions
8893
// if ada_is_valid(result) is false, functions below will return false
8994
bool ada_has_credentials(ada_url result);

doc/contributing/maintaining/maintaining-dependencies.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ All dependencies are located within the `deps` directory.
99
This a list of all the dependencies:
1010

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

153-
### ada 2.6.3
153+
### ada 2.6.5
154154

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

321321
[acorn 8.10.0]: #acorn-8100
322-
[ada 2.6.3]: #ada-263
322+
[ada 2.6.5]: #ada-265
323323
[base64 0.5.0]: #base64-050
324324
[brotli 1.0.9]: #brotli-109
325325
[c-ares 1.19.0]: #c-ares-1190

0 commit comments

Comments
 (0)