Skip to content

Commit

Permalink
Bug 1337144 - don't use RemoveElementAt(0) in APZ's Axis class; r=botond
Browse files Browse the repository at this point in the history
We can more simply perform any processing we need, and then use Clear to
clear the array in one go.
  • Loading branch information
froydnj committed Feb 8, 2017
1 parent 3601646 commit 8c0f3e0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions gfx/layers/apz/src/Axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,14 @@ void Axis::EndTouch(uint32_t aTimestampMs) {
mAxisLocked = false;
mVelocity = 0;
int count = 0;
while (!mVelocityQueue.IsEmpty()) {
uint32_t timeDelta = (aTimestampMs - mVelocityQueue[0].first);
for (const auto& e : mVelocityQueue) {
uint32_t timeDelta = (aTimestampMs - e.first);
if (timeDelta < gfxPrefs::APZVelocityRelevanceTime()) {
count++;
mVelocity += mVelocityQueue[0].second;
mVelocity += e.second;
}
mVelocityQueue.RemoveElementAt(0);
}
mVelocityQueue.Clear();
if (count > 1) {
mVelocity /= count;
}
Expand All @@ -333,9 +333,7 @@ void Axis::CancelGesture() {
AXIS_LOG("%p|%s cancelling touch, clearing velocity queue\n",
mAsyncPanZoomController, Name());
mVelocity = 0.0f;
while (!mVelocityQueue.IsEmpty()) {
mVelocityQueue.RemoveElementAt(0);
}
mVelocityQueue.Clear();
}

bool Axis::CanScroll() const {
Expand Down

0 comments on commit 8c0f3e0

Please sign in to comment.