From 1b2661ee753b910c183bf25170046a150f1ba7e6 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Mon, 1 Oct 2018 09:55:42 +0000 Subject: [PATCH] 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 --- dom/ipc/TabChild.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 812f8b6256c2..5442fb1864da 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -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 dispatchData = MakeUnique();