mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Everywhere: Make use of container version of all_of
Problem: - New `all_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
2c042e3530
commit
97bd13264a
Notes:
sideshowbarker
2024-07-18 07:32:54 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/97bd13264ab Pull-request: https://github.com/SerenityOS/serenity/pull/9012
10 changed files with 10 additions and 11 deletions
|
@ -199,8 +199,7 @@ private:
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
auto references_all_arguments = AK::all_of(
|
auto references_all_arguments = AK::all_of(
|
||||||
all_parameters.begin(),
|
all_parameters,
|
||||||
all_parameters.end(),
|
|
||||||
[&](auto& entry) {
|
[&](auto& entry) {
|
||||||
return contains(
|
return contains(
|
||||||
check.used_arguments.begin(),
|
check.used_arguments.begin(),
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
|
|
||||||
constexpr bool is_zero() const
|
constexpr bool is_zero() const
|
||||||
{
|
{
|
||||||
return all_of(m_data.begin(), m_data.end(), [](const auto octet) { return octet == 0; });
|
return all_of(m_data, [](const auto octet) { return octet == 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_to(Bytes destination) const
|
void copy_to(Bytes destination) const
|
||||||
|
|
|
@ -284,7 +284,7 @@ bool contains(const StringView& str, const StringView& needle, CaseSensitivity c
|
||||||
|
|
||||||
bool is_whitespace(const StringView& str)
|
bool is_whitespace(const StringView& str)
|
||||||
{
|
{
|
||||||
return all_of(str.begin(), str.end(), is_ascii_space);
|
return all_of(str, is_ascii_space);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView trim(const StringView& str, const StringView& characters, TrimMode mode)
|
StringView trim(const StringView& str, const StringView& characters, TrimMode mode)
|
||||||
|
|
|
@ -70,7 +70,7 @@ bool UUID::operator==(const UUID& other) const
|
||||||
|
|
||||||
bool UUID::is_zero() const
|
bool UUID::is_zero() const
|
||||||
{
|
{
|
||||||
return all_of(m_uuid_buffer.begin(), m_uuid_buffer.end(), [](const auto octet) { return octet == 0; });
|
return all_of(m_uuid_buffer, [](const auto octet) { return octet == 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ bool DiskPartitionMetadata::PartitionType::is_uuid() const
|
||||||
}
|
}
|
||||||
bool DiskPartitionMetadata::PartitionType::is_valid() const
|
bool DiskPartitionMetadata::PartitionType::is_valid() const
|
||||||
{
|
{
|
||||||
return !all_of(m_partition_type.begin(), m_partition_type.end(), [](const auto octet) { return octet == 0; });
|
return !all_of(m_partition_type, [](const auto octet) { return octet == 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskPartitionMetadata::DiskPartitionMetadata(u64 start_block, u64 end_block, u8 partition_type)
|
DiskPartitionMetadata::DiskPartitionMetadata(u64 start_block, u64 end_block, u8 partition_type)
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool GUIDPartitionTable::initialize()
|
||||||
|
|
||||||
bool GUIDPartitionTable::is_unused_entry(Array<u8, 16> partition_type) const
|
bool GUIDPartitionTable::is_unused_entry(Array<u8, 16> partition_type) const
|
||||||
{
|
{
|
||||||
return all_of(partition_type.begin(), partition_type.end(), [](const auto octet) { return octet == 0; });
|
return all_of(partition_type, [](const auto octet) { return octet == 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ String serialize_astring(StringView string)
|
||||||
auto non_atom_chars = { '(', ')', '{', ' ', '%', '*', '"', '\\', ']' };
|
auto non_atom_chars = { '(', ')', '{', ' ', '%', '*', '"', '\\', ']' };
|
||||||
return AK::find(non_atom_chars.begin(), non_atom_chars.end(), x) != non_atom_chars.end();
|
return AK::find(non_atom_chars.begin(), non_atom_chars.end(), x) != non_atom_chars.end();
|
||||||
};
|
};
|
||||||
auto is_atom = all_of(string.begin(), string.end(), [&](auto ch) { return is_ascii_control(ch) && !is_non_atom_char(ch); });
|
auto is_atom = all_of(string, [&](auto ch) { return is_ascii_control(ch) && !is_non_atom_char(ch); });
|
||||||
if (is_atom) {
|
if (is_atom) {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ OrdinaryFunctionObject::OrdinaryFunctionObject(GlobalObject& global_object, cons
|
||||||
set_this_mode(ThisMode::Global);
|
set_this_mode(ThisMode::Global);
|
||||||
|
|
||||||
// 15.1.3 Static Semantics: IsSimpleParameterList, https://tc39.es/ecma262/#sec-static-semantics-issimpleparameterlist
|
// 15.1.3 Static Semantics: IsSimpleParameterList, https://tc39.es/ecma262/#sec-static-semantics-issimpleparameterlist
|
||||||
set_has_simple_parameter_list(all_of(m_parameters.begin(), m_parameters.end(), [&](auto& parameter) {
|
set_has_simple_parameter_list(all_of(m_parameters, [&](auto& parameter) {
|
||||||
if (parameter.is_rest)
|
if (parameter.is_rest)
|
||||||
return false;
|
return false;
|
||||||
if (parameter.default_value)
|
if (parameter.default_value)
|
||||||
|
|
|
@ -53,7 +53,7 @@ static bool is_valid_bigint_value(StringView string)
|
||||||
string = string.trim_whitespace();
|
string = string.trim_whitespace();
|
||||||
if (string.length() > 1 && (string[0] == '-' || string[0] == '+'))
|
if (string.length() > 1 && (string[0] == '-' || string[0] == '+'))
|
||||||
string = string.substring_view(1, string.length() - 1);
|
string = string.substring_view(1, string.length() - 1);
|
||||||
return all_of(string.begin(), string.end(), [](auto ch) { return isdigit(ch); });
|
return all_of(string, [](auto ch) { return isdigit(ch); });
|
||||||
}
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE bool both_number(const Value& lhs, const Value& rhs)
|
ALWAYS_INLINE bool both_number(const Value& lhs, const Value& rhs)
|
||||||
|
|
|
@ -231,7 +231,7 @@ Optional<Core::DateTime> parse_date_time(StringView date_string)
|
||||||
unsigned year = 0;
|
unsigned year = 0;
|
||||||
|
|
||||||
auto to_uint = [](StringView token, unsigned& result) {
|
auto to_uint = [](StringView token, unsigned& result) {
|
||||||
if (!all_of(token.begin(), token.end(), isdigit))
|
if (!all_of(token, isdigit))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (auto converted = token.to_uint(); converted.has_value()) {
|
if (auto converted = token.to_uint(); converted.has_value()) {
|
||||||
|
|
Loading…
Reference in a new issue