diff --git a/AK/HashMap.h b/AK/HashMap.h index 50abecd6380..4d61cede6ae 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -77,7 +77,7 @@ public: } template - bool remove_all_matching(TUnaryPredicate predicate) + bool remove_all_matching(TUnaryPredicate const& predicate) { return m_table.template remove_all_matching([&](auto& entry) { return predicate(entry.key, entry.value); diff --git a/AK/HashTable.h b/AK/HashTable.h index 14478b47011..c9cfbabfa90 100644 --- a/AK/HashTable.h +++ b/AK/HashTable.h @@ -422,7 +422,7 @@ public: } template - bool remove_all_matching(TUnaryPredicate predicate) + bool remove_all_matching(TUnaryPredicate const& predicate) { size_t removed_count = 0; for (size_t i = 0; i < m_capacity; ++i) { diff --git a/AK/Vector.h b/AK/Vector.h index a68628282e1..c56761e369a 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -163,7 +163,7 @@ public: VisibleType& last() { return at(size() - 1); } template - Optional first_matching(TUnaryPredicate predicate) requires(!contains_reference) + Optional first_matching(TUnaryPredicate const& predicate) requires(!contains_reference) { for (size_t i = 0; i < size(); ++i) { if (predicate(at(i))) { @@ -174,7 +174,7 @@ public: } template - Optional first_matching(TUnaryPredicate predicate) const requires(!contains_reference) + Optional first_matching(TUnaryPredicate const& predicate) const requires(!contains_reference) { for (size_t i = 0; i < size(); ++i) { if (predicate(at(i))) { @@ -185,7 +185,7 @@ public: } template - Optional last_matching(TUnaryPredicate predicate) requires(!contains_reference) + Optional last_matching(TUnaryPredicate const& predicate) requires(!contains_reference) { for (ssize_t i = size() - 1; i >= 0; --i) { if (predicate(at(i))) { @@ -233,7 +233,7 @@ public: } template - void insert_before_matching(U&& value, TUnaryPredicate predicate, size_t first_index = 0, size_t* inserted_index = nullptr) requires(CanBePlacedInsideVector) + void insert_before_matching(U&& value, TUnaryPredicate const& predicate, size_t first_index = 0, size_t* inserted_index = nullptr) requires(CanBePlacedInsideVector) { MUST(try_insert_before_matching(forward(value), predicate, first_index, inserted_index)); } @@ -415,7 +415,7 @@ public: } template - bool remove_first_matching(TUnaryPredicate predicate) + bool remove_first_matching(TUnaryPredicate const& predicate) { for (size_t i = 0; i < size(); ++i) { if (predicate(at(i))) { @@ -427,7 +427,7 @@ public: } template - bool remove_all_matching(TUnaryPredicate predicate) + bool remove_all_matching(TUnaryPredicate const& predicate) { bool something_was_removed = false; for (size_t i = 0; i < size();) { @@ -507,7 +507,7 @@ public: } template - ErrorOr try_insert_before_matching(U&& value, TUnaryPredicate predicate, size_t first_index = 0, size_t* inserted_index = nullptr) requires(CanBePlacedInsideVector) + ErrorOr try_insert_before_matching(U&& value, TUnaryPredicate const& predicate, size_t first_index = 0, size_t* inserted_index = nullptr) requires(CanBePlacedInsideVector) { for (size_t i = first_index; i < size(); ++i) { if (predicate(at(i))) { diff --git a/Userland/Libraries/LibGUI/ModelSelection.cpp b/Userland/Libraries/LibGUI/ModelSelection.cpp index 8e11c3f4231..6fac46b8f17 100644 --- a/Userland/Libraries/LibGUI/ModelSelection.cpp +++ b/Userland/Libraries/LibGUI/ModelSelection.cpp @@ -10,9 +10,9 @@ namespace GUI { -void ModelSelection::remove_all_matching(Function filter) +void ModelSelection::remove_all_matching(Function const& filter) { - if (m_indices.remove_all_matching([&](ModelIndex const& index) { return filter(index); })) + if (m_indices.remove_all_matching(filter)) notify_selection_changed(); } diff --git a/Userland/Libraries/LibGUI/ModelSelection.h b/Userland/Libraries/LibGUI/ModelSelection.h index b89d632012e..79592159aad 100644 --- a/Userland/Libraries/LibGUI/ModelSelection.h +++ b/Userland/Libraries/LibGUI/ModelSelection.h @@ -76,7 +76,7 @@ public: return *m_indices.begin(); } - void remove_all_matching(Function filter); + void remove_all_matching(Function const& filter); template void change_from_model(Badge, Function f)