Skip to content

Commit 6dc4da4

Browse files
rubennortefacebook-github-bot
authored andcommitted
Refactor event dispatching logic to improve readability and performance slightly (#50991)
Summary: Pull Request resolved: #50991 Changelog: [internal] TSIA. Reviewed By: javache Differential Revision: D73853068 fbshipit-source-id: 93e33072e4ce14225cc76ca8daf5d8816489ac7b
1 parent 030ca3c commit 6dc4da4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/react-native/ReactCommon/react/renderer/core/EventQueue.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ void EventQueue::enqueueEvent(RawEvent&& rawEvent) const {
3434
auto repeatedEvent = eventQueue_.rend();
3535

3636
for (auto it = eventQueue_.rbegin(); it != eventQueue_.rend(); ++it) {
37-
if (it->type == rawEvent.type &&
38-
it->eventTarget == rawEvent.eventTarget && it->isUnique) {
39-
repeatedEvent = it;
40-
break;
41-
} else if (it->eventTarget == rawEvent.eventTarget) {
37+
if (it->eventTarget == rawEvent.eventTarget) {
4238
// It is necessary to maintain order of different event types
4339
// for the same target. If the same target has event types A1, B1
4440
// in the event queue and event A2 occurs. A1 has to stay in the
4541
// queue.
42+
if (it->isUnique && it->type == rawEvent.type) {
43+
repeatedEvent = it;
44+
}
45+
4646
break;
4747
}
4848
}

0 commit comments

Comments
 (0)