Use std::erase_if to simplify removal of items
This function makes it simpler to remove items from collections. Update
our code to make it more readable.
Bug: 198472780
Test: presubmit
Change-Id: I3bc81bf729e9b22ced16691272187870783c1728
diff --git a/services/inputflinger/BlockingQueue.h b/services/inputflinger/BlockingQueue.h
index b612ca7..8300e8a 100644
--- a/services/inputflinger/BlockingQueue.h
+++ b/services/inputflinger/BlockingQueue.h
@@ -71,8 +71,7 @@
void erase(const std::function<bool(const T&)>& lambda) {
std::scoped_lock lock(mLock);
- mQueue.erase(std::remove_if(mQueue.begin(), mQueue.end(),
- [&lambda](const T& t) { return lambda(t); }), mQueue.end());
+ std::erase_if(mQueue, [&lambda](const auto& t) { return lambda(t); });
}
/**