Bug 1494978 - Use LookupOrAdd to simplify hashtable lookup in mouse event coalescence; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D7179

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Edgar Chen 2018-10-01 09:55:42 +00:00
Родитель ee4552163c
Коммит 1b2661ee75
1 изменённых файлов: 2 добавлений и 7 удалений

Просмотреть файл

@ -1618,12 +1618,8 @@ TabChild::RecvRealMouseMoveEvent(const WidgetMouseEvent& aEvent,
const uint64_t& aInputBlockId)
{
if (mCoalesceMouseMoveEvents && mCoalescedMouseEventFlusher) {
CoalescedMouseData* data = nullptr;
mCoalescedMouseData.Get(aEvent.pointerId, &data);
if (!data) {
data = new CoalescedMouseData();
mCoalescedMouseData.Put(aEvent.pointerId, data);
}
CoalescedMouseData* data = mCoalescedMouseData.LookupOrAdd(aEvent.pointerId);
MOZ_ASSERT(data);
if (data->CanCoalesce(aEvent, aGuid, aInputBlockId)) {
data->Coalesce(aEvent, aGuid, aInputBlockId);
mCoalescedMouseEventFlusher->StartObserver();
@ -1632,7 +1628,6 @@ TabChild::RecvRealMouseMoveEvent(const WidgetMouseEvent& aEvent,
// Can't coalesce current mousemove event. Put the coalesced mousemove data
// with the same pointer id to mToBeDispatchedMouseData, coalesce the
// current one, and process all pending data in mToBeDispatchedMouseData.
MOZ_ASSERT(data);
UniquePtr<CoalescedMouseData> dispatchData =
MakeUnique<CoalescedMouseData>();