Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9e843ac authored by Greg Kaiser's avatar Greg Kaiser
Browse files

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
parent 945a7006
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ namespace android {
//         >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();
    }
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ struct CallbackIdsHash {
    // 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());
    }
};