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

Commit 226a6526 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use bitwise operator to remove pointers"

parents 814dd22d 9af4e115
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -164,17 +164,7 @@ void TouchState::cancelPointersForNonPilferingWindows() {
    std::for_each(windows.begin(), windows.end(), [&allPilferedPointerIds](TouchedWindow& w) {
        std::bitset<MAX_POINTER_ID + 1> pilferedByOtherWindows =
                w.pilferedPointerIds ^ allPilferedPointerIds;
        // TODO(b/211379801) : convert pointerIds to use std::bitset, which would allow us to
        // replace the loop below with a bitwise operation. Currently, the XOR operation above is
        // redundant, but is done to make the code more explicit / easier to convert later.
        for (std::size_t i = 0; i < pilferedByOtherWindows.size(); i++) {
            if (pilferedByOtherWindows.test(i) && !w.pilferedPointerIds.test(i)) {
                // Pointer is pilfered by other windows, but not by this one! Remove it from here.
                // We could call 'removeTouchedPointerFromWindow' here, but it's faster to directly
                // manipulate it.
                w.pointerIds.reset(i);
            }
        }
        w.pointerIds &= ~pilferedByOtherWindows;
    });
    std::erase_if(windows, [](const TouchedWindow& w) { return w.pointerIds.none(); });
}