diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp index 055e9c59ec4..55bc9c7b0aa 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.cpp +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.cpp @@ -13,10 +13,8 @@ namespace react { BatchedEventQueue::BatchedEventQueue( EventPipe eventPipe, StatePipe statePipe, - std::unique_ptr eventBeat, - bool enableV2EventCoalescing) - : EventQueue(eventPipe, statePipe, std::move(eventBeat)), - enableV2EventCoalescing_(enableV2EventCoalescing) {} + std::unique_ptr eventBeat) + : EventQueue(eventPipe, statePipe, std::move(eventBeat)) {} void BatchedEventQueue::onEnqueue() const { EventQueue::onEnqueue(); @@ -28,38 +26,26 @@ void BatchedEventQueue::enqueueUniqueEvent(RawEvent const &rawEvent) const { { std::lock_guard lock(queueMutex_); - if (enableV2EventCoalescing_) { - auto repeatedEvent = eventQueue_.rend(); + auto repeatedEvent = eventQueue_.rend(); - for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) { - if (it->type == rawEvent.type && - it->eventTarget == rawEvent.eventTarget) { - repeatedEvent = it; - break; - } else if (it->eventTarget == rawEvent.eventTarget) { - // It is necessary to maintain order of different event types - // for the same target. If the same target has event types A1, B1 - // in the event queue and event A2 occurs. A1 has to stay in the - // queue. - break; - } - } - - if (repeatedEvent == eventQueue_.rend()) { - eventQueue_.push_back(rawEvent); - } else { - *repeatedEvent = std::move(rawEvent); - } - } else { - if (!eventQueue_.empty()) { - auto const position = eventQueue_.back(); - if (position.type == rawEvent.type && - position.eventTarget == rawEvent.eventTarget) { - eventQueue_.pop_back(); - } + for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) { + if (it->type == rawEvent.type && + it->eventTarget == rawEvent.eventTarget) { + repeatedEvent = it; + break; + } else if (it->eventTarget == rawEvent.eventTarget) { + // It is necessary to maintain order of different event types + // for the same target. If the same target has event types A1, B1 + // in the event queue and event A2 occurs. A1 has to stay in the + // queue. + break; } + } + if (repeatedEvent == eventQueue_.rend()) { eventQueue_.push_back(rawEvent); + } else { + *repeatedEvent = std::move(rawEvent); } } diff --git a/ReactCommon/react/renderer/core/BatchedEventQueue.h b/ReactCommon/react/renderer/core/BatchedEventQueue.h index 85f7c8bca45..827ef87886e 100644 --- a/ReactCommon/react/renderer/core/BatchedEventQueue.h +++ b/ReactCommon/react/renderer/core/BatchedEventQueue.h @@ -21,8 +21,7 @@ class BatchedEventQueue final : public EventQueue { BatchedEventQueue( EventPipe eventPipe, StatePipe statePipe, - std::unique_ptr eventBeat, - bool enableV2EventCoalescing); + std::unique_ptr eventBeat); void onEnqueue() const override; @@ -32,9 +31,6 @@ class BatchedEventQueue final : public EventQueue { * Can be called on any thread. */ void enqueueUniqueEvent(const RawEvent &rawEvent) const; - - private: - bool const enableV2EventCoalescing_; }; } // namespace react diff --git a/ReactCommon/react/renderer/core/EventDispatcher.cpp b/ReactCommon/react/renderer/core/EventDispatcher.cpp index 75d04608287..8ece2ab3a07 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.cpp +++ b/ReactCommon/react/renderer/core/EventDispatcher.cpp @@ -21,8 +21,7 @@ EventDispatcher::EventDispatcher( StatePipe const &statePipe, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, - EventBeat::SharedOwnerBox const &ownerBox, - bool enableV2EventCoalescing) + EventBeat::SharedOwnerBox const &ownerBox) : synchronousUnbatchedQueue_(std::make_unique( eventPipe, statePipe, @@ -30,8 +29,7 @@ EventDispatcher::EventDispatcher( synchronousBatchedQueue_(std::make_unique( eventPipe, statePipe, - synchonousEventBeatFactory(ownerBox), - enableV2EventCoalescing)), + synchonousEventBeatFactory(ownerBox))), asynchronousUnbatchedQueue_(std::make_unique( eventPipe, statePipe, @@ -39,8 +37,7 @@ EventDispatcher::EventDispatcher( asynchronousBatchedQueue_(std::make_unique( eventPipe, statePipe, - asynchonousEventBeatFactory(ownerBox), - enableV2EventCoalescing)) {} + asynchonousEventBeatFactory(ownerBox))) {} void EventDispatcher::dispatchEvent( RawEvent const &rawEvent, diff --git a/ReactCommon/react/renderer/core/EventDispatcher.h b/ReactCommon/react/renderer/core/EventDispatcher.h index eb0abf52eba..d3fb37c1327 100644 --- a/ReactCommon/react/renderer/core/EventDispatcher.h +++ b/ReactCommon/react/renderer/core/EventDispatcher.h @@ -37,8 +37,7 @@ class EventDispatcher { StatePipe const &statePipe, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, - EventBeat::SharedOwnerBox const &ownerBox, - bool enableV2EventCoalescing); + EventBeat::SharedOwnerBox const &ownerBox); /* * Dispatches a raw event with given priority using event-delivery pipe. diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 313b4e201ec..648b1116844 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -67,8 +67,7 @@ Scheduler::Scheduler( statePipe, schedulerToolbox.synchronousEventBeatFactory, schedulerToolbox.asynchronousEventBeatFactory, - eventOwnerBox, - reactNativeConfig_->getBool("react_fabric:enable_v2_event_coalescing")); + eventOwnerBox); // Casting to `std::shared_ptr`. auto eventDispatcher =