From bc749a16238d37336d8912f7b5cd54fc1ea5b212 Mon Sep 17 00:00:00 2001 From: Genki Kondo Date: Tue, 21 Feb 2023 16:17:30 -0800 Subject: [PATCH] Early exit during matching in EventAnimationDriverMatchSpec Summary: Simple optimization to exit before iterating through the hit path if the event name doesn't match. Changelog: [Android][Internal] - Optimization for natively-driven Animated PointerEvents to early exit during matching in EventAnimationDriverMatchSpec. This should have no effect if you are not using PointerEvents Reviewed By: lunaleaps Differential Revision: D43400457 fbshipit-source-id: fe8d811d371c78622cd4f3f9cd469cff9ccce585 --- .../com/facebook/react/uimanager/events/PointerEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEvent.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEvent.java index 3d46a854982dce..704859c8f273d1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEvent.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEvent.java @@ -124,14 +124,14 @@ public Event.EventAnimationDriverMatchSpec getEventAnimationDriverMatchSpec() { new EventAnimationDriverMatchSpec() { @Override public boolean match(int viewTag, String eventName) { - if (!PointerEventHelper.isBubblingEvent(eventName)) { + if (!eventName.equals(mEventName) || !PointerEventHelper.isBubblingEvent(eventName)) { return false; } List viewTargets = mEventState.getHitPathForActivePointer(); for (TouchTargetHelper.ViewTarget viewTarget : viewTargets) { - if (viewTarget.getViewId() == viewTag && eventName.equals(mEventName)) { + if (viewTarget.getViewId() == viewTag) { return true; } }