Skip to content

Commit b431670

Browse files
committed
update ada::idna to c++20
1 parent 4ace34b commit b431670

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

include/ada/ada_idna.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2023-09-19 15:58:51 -0400. Do not edit! */
1+
/* auto-generated on 2024-09-03 10:55:13 -0400. Do not edit! */
22
/* begin file include/idna.h */
33
#ifndef ADA_IDNA_H
44
#define ADA_IDNA_H
@@ -119,9 +119,6 @@ std::string to_ascii(std::string_view ut8_string);
119119
// https://url.spec.whatwg.org/#forbidden-domain-code-point
120120
bool contains_forbidden_domain_code_point(std::string_view ascii_string);
121121

122-
bool begins_with(std::u32string_view view, std::u32string_view prefix);
123-
bool begins_with(std::string_view view, std::string_view prefix);
124-
125122
bool constexpr is_ascii(std::u32string_view view);
126123
bool constexpr is_ascii(std::string_view view);
127124

src/ada_idna.cpp

+4-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2023-09-19 15:58:51 -0400. Do not edit! */
1+
/* auto-generated on 2024-09-03 10:55:13 -0400. Do not edit! */
22
/* begin file src/idna.cpp */
33
/* begin file src/unicode_transcoding.cpp */
44

@@ -9387,22 +9387,6 @@ bool is_label_valid(const std::u32string_view label) {
93879387

93889388
namespace ada::idna {
93899389

9390-
bool begins_with(std::u32string_view view, std::u32string_view prefix) {
9391-
if (view.size() < prefix.size()) {
9392-
return false;
9393-
}
9394-
// constexpr as of C++20
9395-
return std::equal(prefix.begin(), prefix.end(), view.begin());
9396-
}
9397-
9398-
bool begins_with(std::string_view view, std::string_view prefix) {
9399-
if (view.size() < prefix.size()) {
9400-
return false;
9401-
}
9402-
// constexpr as of C++20
9403-
return std::equal(prefix.begin(), prefix.end(), view.begin());
9404-
}
9405-
94069390
bool constexpr is_ascii(std::u32string_view view) {
94079391
for (uint32_t c : view) {
94089392
if (c >= 0x80) {
@@ -9465,7 +9449,7 @@ static std::string from_ascii_to_ascii(std::string_view ut8_string) {
94659449
label_start += label_size_with_dot;
94669450
if (label_size == 0) {
94679451
// empty label? Nothing to do.
9468-
} else if (begins_with(label_view, "xn--")) {
9452+
} else if (label_view.starts_with("xn--")) {
94699453
// The xn-- part is the expensive game.
94709454
out.append(label_view);
94719455
std::string_view puny_segment_ascii(
@@ -9532,7 +9516,7 @@ std::string to_ascii(std::string_view ut8_string) {
95329516
label_start += label_size_with_dot;
95339517
if (label_size == 0) {
95349518
// empty label? Nothing to do.
9535-
} else if (begins_with(label_view, U"xn--")) {
9519+
} else if (label_view.starts_with(U"xn--")) {
95369520
// we do not need to check, e.g., Xn-- because mapping goes to lower case
95379521
for (char32_t c : label_view) {
95389522
if (c >= 0x80) {
@@ -9611,8 +9595,7 @@ std::string to_unicode(std::string_view input) {
96119595
is_last_label ? input.size() - label_start : loc_dot - label_start;
96129596
auto label_view = std::string_view(input.data() + label_start, label_size);
96139597

9614-
if (ada::idna::begins_with(label_view, "xn--") &&
9615-
ada::idna::is_ascii(label_view)) {
9598+
if (label_view.starts_with("xn--") && ada::idna::is_ascii(label_view)) {
96169599
label_view.remove_prefix(4);
96179600
if (ada::idna::verify_punycode(label_view)) {
96189601
std::u32string tmp_buffer;

0 commit comments

Comments
 (0)