Commit 9d46fa38 authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[Code cleanup] Don't remove an event from queue if it is not intended to

Right now at PassthroughTouchEventQueue::ProcessTouchAck, we fetch an
event from outstanding_touches_ queue, modify its ack info and latency
info, and put the event back in the queue again.

Note that the outstanding_touches_ is a std::set sorted according to
each event's unique_touch_id. Setting ack info and latency info won't
change the unique_touch_id on the event, in order words, it won't affect
the ordering of the event in that set. So it is un-necessary to remove
the event and put it back in the queue again.

This CL does clean up. It sets ack and latency info directly on the
event in the outstanding_touches_. The only catch here is that the iter
of a std::set is always const, so we have to do a const_cast.

Bug: None
Change-Id: I45cf1001ce82b3fd876b856618c99df25d5b9b4a
Reviewed-on: https://chromium-review.googlesource.com/c/1297714Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607245}
parent a1cdcfdc
...@@ -133,11 +133,10 @@ void PassthroughTouchEventQueue::ProcessTouchAck( ...@@ -133,11 +133,10 @@ void PassthroughTouchEventQueue::ProcessTouchAck(
if (touch_event_iter == outstanding_touches_.end()) if (touch_event_iter == outstanding_touches_.end())
return; return;
TouchEventWithLatencyInfoAndAckState event = *touch_event_iter; TouchEventWithLatencyInfoAndAckState& event =
touch_event_iter = outstanding_touches_.erase(touch_event_iter); const_cast<TouchEventWithLatencyInfoAndAckState&>(*touch_event_iter);
event.latency.AddNewLatencyFrom(latency_info); event.latency.AddNewLatencyFrom(latency_info);
event.set_ack_info(ack_source, ack_result); event.set_ack_info(ack_source, ack_result);
outstanding_touches_.insert(touch_event_iter, event);
AckCompletedEvents(); AckCompletedEvents();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment