Skip to content

Commit

Permalink
remove unnecessary duplicate_name method
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jan 1, 2025
1 parent 4386553 commit ea7e886
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 2 additions & 9 deletions include/ada/url_pattern_helpers-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ std::optional<url_pattern_errors> url_pattern_parser<F>::add_part(
}
// If the result of running is a duplicate name given parser and name is
// true, then throw a TypeError.
if (is_duplicate_name(name)) {
if (std::ranges::any_of(
parts, [&name](const auto& part) { return part.name == name; })) {
return url_pattern_errors::type_error;
}
// Let encoded prefix be the result of running parser’s encoding callback
Expand All @@ -638,14 +639,6 @@ std::optional<url_pattern_errors> url_pattern_parser<F>::add_part(
return std::nullopt;
}

template <url_pattern_encoding_callback F>
bool url_pattern_parser<F>::is_duplicate_name(std::string_view name) {
// For each part of parser’s part list:
// If part’s name is name, then return true.
return std::ranges::any_of(
parts, [&name](const auto& part) { return part.name == name; });
}

template <url_pattern_encoding_callback F>
tl::expected<std::vector<url_pattern_part>, url_pattern_errors>
parse_pattern_string(std::string_view input,
Expand Down
2 changes: 0 additions & 2 deletions include/ada/url_pattern_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class url_pattern_parser {
std::string_view prefix, Token* name_token,
Token* regexp_or_wildcard_token, std::string_view suyffix,
Token* modifier_token) ada_warn_unused;
// @see https://urlpattern.spec.whatwg.org/#is-a-duplicate-name
bool is_duplicate_name(std::string_view name);

std::vector<Token> tokens{};
F& encoding_callback;
Expand Down

0 comments on commit ea7e886

Please sign in to comment.