surfaceflinger: Avoid extra vector copies
We pass a std::vector by const reference in a couple places in
TransactionCompletedThread to avoid making an extra copy.
Test: TreeHugger
Change-Id: Ie81a27b80e52a1890d54b4507d0fcbf30e746e7b
diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp
index 1d2217d..6b2b583 100644
--- a/services/surfaceflinger/TransactionCompletedThread.cpp
+++ b/services/surfaceflinger/TransactionCompletedThread.cpp
@@ -34,7 +34,8 @@
// >0 if the first id that doesn't match is greater in c2 or all ids match but c2 is longer
//
// See CallbackIdsHash for a explaniation of why this works
-static int compareCallbackIds(const std::vector<CallbackId>& c1, const std::vector<CallbackId> c2) {
+static int compareCallbackIds(const std::vector<CallbackId>& c1,
+ const std::vector<CallbackId>& c2) {
if (c1.empty()) {
return !c2.empty();
}
diff --git a/services/surfaceflinger/TransactionCompletedThread.h b/services/surfaceflinger/TransactionCompletedThread.h
index 09feb75..21e2678 100644
--- a/services/surfaceflinger/TransactionCompletedThread.h
+++ b/services/surfaceflinger/TransactionCompletedThread.h
@@ -37,7 +37,7 @@
// 2) CallbackId vectors for the same listener either are identical or contain none of the
// same members. It is sufficient to just check the first CallbackId in the vectors. If
// they match, they are the same. If they do not match, they are not the same.
- std::size_t operator()(const std::vector<CallbackId> callbackIds) const {
+ std::size_t operator()(const std::vector<CallbackId>& callbackIds) const {
return std::hash<CallbackId>{}((callbackIds.empty()) ? 0 : callbackIds.front());
}
};