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/dispatcher/TouchState.cpp b/services/inputflinger/dispatcher/TouchState.cpp
index d624e99..08c7826 100644
--- a/services/inputflinger/dispatcher/TouchState.cpp
+++ b/services/inputflinger/dispatcher/TouchState.cpp
@@ -106,10 +106,8 @@
}
void TouchState::filterWindowsExcept(const sp<IBinder>& token) {
- auto it = std::remove_if(windows.begin(), windows.end(), [&token](const TouchedWindow& w) {
- return w.windowHandle->getToken() != token;
- });
- windows.erase(it, windows.end());
+ std::erase_if(windows,
+ [&token](const TouchedWindow& w) { return w.windowHandle->getToken() != token; });
}
sp<WindowInfoHandle> TouchState::getFirstForegroundWindowHandle() const {