mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +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
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)
|
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;
|
return word == str;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expe
|
||||||
if (match(TokenType::CurlyOpen)) {
|
if (match(TokenType::CurlyOpen)) {
|
||||||
// Parse a function body with statements
|
// Parse a function body with statements
|
||||||
ScopePusher scope(*this, ScopePusher::Var, Scope::Function);
|
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>>();
|
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);
|
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>>();
|
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)
|
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?
|
// 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");
|
syntax_error("Binding pattern target may not be a reserved word");
|
||||||
} else if (m_state.strict_mode || force_strict) {
|
} else if (m_state.strict_mode || force_strict) {
|
||||||
if (name.is_one_of("arguments"sv, "eval"sv))
|
if (name.is_one_of("arguments"sv, "eval"sv))
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
bool is_empty() const
|
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
|
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
|
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
|
return case_sensitivity == CaseSensitivity::CaseSensitive
|
||||||
? it == class_name
|
? it == class_name
|
||||||
: it.to_lowercase() == class_name.to_lowercase();
|
: it.to_lowercase() == class_name.to_lowercase();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue