mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Reimplement any_of in terms of find_if
Problem: - Now that a generic free-function form of `find_if` is implemented the code in `any_of` is redundant. Solution: - Follow the "don't repeat yourself" mantra and make the code DRY by implementing `any_of` in terms of `find_if`.
This commit is contained in:
parent
25c73159ce
commit
24225df979
Notes:
sideshowbarker
2024-07-18 12:00:20 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/24225df979e Pull-request: https://github.com/SerenityOS/serenity/pull/8012
1 changed files with 2 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Find.h>
|
||||
#include <AK/Iterator.h>
|
||||
|
||||
namespace AK {
|
||||
|
@ -16,12 +17,7 @@ constexpr bool any_of(
|
|||
const SimpleIterator<Container, ValueType>& end,
|
||||
const auto& predicate)
|
||||
{
|
||||
for (auto iter = begin; iter != end; ++iter) {
|
||||
if (predicate(*iter)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return find_if(begin, end, predicate) != end;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue