mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Userland: Make use of container version of any_of
Problem: - New `any_of` implementation takes the entire container so the user does not need to pass explicit begin/end iterators. This is unused except is in tests. Solution: - Make use of the new and more user-friendly version where possible.
This commit is contained in:
parent
cb9de1d741
commit
a0d7640e03
Notes:
sideshowbarker
2024-07-18 07:37:08 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/a0d7640e034 Pull-request: https://github.com/SerenityOS/serenity/pull/9010 Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 6 additions and 6 deletions
|
@ -411,7 +411,7 @@ static constexpr AK::Array<StringView, 9> strict_reserved_words = { "implements"
|
|||
|
||||
static bool is_strict_reserved_word(StringView str)
|
||||
{
|
||||
return any_of(strict_reserved_words.begin(), strict_reserved_words.end(), [&str](StringView const& word) {
|
||||
return any_of(strict_reserved_words, [&str](StringView const& word) {
|
||||
return word == str;
|
||||
});
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expe
|
|||
if (match(TokenType::CurlyOpen)) {
|
||||
// Parse a function body with statements
|
||||
ScopePusher scope(*this, ScopePusher::Var, Scope::Function);
|
||||
bool has_binding = any_of(parameters.begin(), parameters.end(), [&](FunctionNode::Parameter const& parameter) {
|
||||
bool has_binding = any_of(parameters, [](FunctionNode::Parameter const& parameter) {
|
||||
return parameter.binding.has<NonnullRefPtr<BindingPattern>>();
|
||||
});
|
||||
|
||||
|
@ -1705,7 +1705,7 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u8 parse_options)
|
|||
|
||||
m_state.function_parameters.append(parameters);
|
||||
|
||||
bool has_binding = any_of(parameters.begin(), parameters.end(), [&](FunctionNode::Parameter const& parameter) {
|
||||
bool has_binding = any_of(parameters, [](FunctionNode::Parameter const& parameter) {
|
||||
return parameter.binding.has<NonnullRefPtr<BindingPattern>>();
|
||||
});
|
||||
|
||||
|
@ -2794,7 +2794,7 @@ void Parser::discard_saved_state()
|
|||
void Parser::check_identifier_name_for_assignment_validity(StringView name, bool force_strict)
|
||||
{
|
||||
// FIXME: this is now called from multiple places maybe the error message should be dynamic?
|
||||
if (any_of(s_reserved_words.begin(), s_reserved_words.end(), [&](auto& value) { return name == value; })) {
|
||||
if (any_of(s_reserved_words, [&](auto& value) { return name == value; })) {
|
||||
syntax_error("Binding pattern target may not be a reserved word");
|
||||
} else if (m_state.strict_mode || force_strict) {
|
||||
if (name.is_one_of("arguments"sv, "eval"sv))
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
bool is_empty() const
|
||||
{
|
||||
return !any_of(m_cells.begin(), m_cells.end(), [](auto& cell) { return cell != Cell(); });
|
||||
return !any_of(m_cells, [](auto& cell) { return cell != Cell(); });
|
||||
}
|
||||
|
||||
size_t length() const
|
||||
|
|
|
@ -91,7 +91,7 @@ void Element::remove_attribute(const FlyString& name)
|
|||
|
||||
bool Element::has_class(const FlyString& class_name, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
return any_of(m_classes.begin(), m_classes.end(), [&](auto& it) {
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
return case_sensitivity == CaseSensitivity::CaseSensitive
|
||||
? it == class_name
|
||||
: it.to_lowercase() == class_name.to_lowercase();
|
||||
|
|
Loading…
Reference in a new issue