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

Commit 9dc758ec authored by Yeabkal Wubshit's avatar Yeabkal Wubshit Committed by Android (Google) Code Review
Browse files

Merge "Avoid RingBuffer creation on each VelocityTracker#add call"

parents d26372a5 540dc07e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -382,8 +382,8 @@ void AccumulatingVelocityTrackerStrategy::clearPointer(int32_t pointerId) {

void AccumulatingVelocityTrackerStrategy::addMovement(nsecs_t eventTime, int32_t pointerId,
                                                      float position) {
    auto [movementIt, _] = mMovements.insert({pointerId, RingBuffer<Movement>(HISTORY_SIZE)});
    RingBuffer<Movement>& movements = movementIt->second;
    auto [ringBufferIt, _] = mMovements.try_emplace(pointerId, HISTORY_SIZE);
    RingBuffer<Movement>& movements = ringBufferIt->second;
    const size_t size = movements.size();

    if (size != 0 && movements[size - 1].eventTime == eventTime) {