Fix for-loop type in dumpDispatchStateLocked
Technically the iterator provides a std::pair<const KEY, VALUE>&, so
we're constructing a std::pair<KEY, VALUE> from it and then taking a
const reference to that. This creates an unnecessary copy but then
obscures that by taking a reference to it. We could use the correct type
to avoid this, but a structured binding is even nicer.
Test: compile
Change-Id: I360c4318001eff503b539693166386160bd605eb
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index eb938c8..de0c0e4 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -5435,9 +5435,7 @@
if (!mReplacedKeys.empty()) {
dump += INDENT "ReplacedKeys:\n";
- for (const std::pair<KeyReplacement, int32_t>& pair : mReplacedKeys) {
- const KeyReplacement& replacement = pair.first;
- int32_t newKeyCode = pair.second;
+ for (const auto& [replacement, newKeyCode] : mReplacedKeys) {
dump += StringPrintf(INDENT2 "originalKeyCode=%d, deviceId=%d -> newKeyCode=%d\n",
replacement.keyCode, replacement.deviceId, newKeyCode);
}