mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 17:30:38 +08:00
Avoid view manager class loads (take 2)
Summary: Second attempt at landing D9930713. Notes about the previous issue is mentioned as an inline comment below. =========== We are currently iterating through each view manager to get its class name to pass to JS. JS uses this list to define lazy property accesses for each view manager to grab the constants synchronously. This results in each view manager's class loading immediately -- causing a small perf hit. Let's avoid this view managers list entirely. JS is able to access each view manager directly by calling getConstantsForViewManager(name) Reviewed By: axe-fb Differential Revision: D10118711 fbshipit-source-id: 78de8f34db364a64f5ce6af70e3d8691353b0d4d
This commit is contained in:
committed by
Facebook Github Bot
parent
e7e63fd409
commit
5be0dff433
@@ -30,7 +30,7 @@ rn_android_library(
|
||||
react_native_target("java/com/facebook/react/animation:animation"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
react_native_target("java/com/facebook/react/config:config"),
|
||||
react_native_target("java/com/facebook/react/module/annotations:annotations"),
|
||||
react_native_target("java/com/facebook/react/modules/core:core"),
|
||||
react_native_target("java/com/facebook/react/modules/i18nmanager:i18nmanager"),
|
||||
|
||||
@@ -10,7 +10,7 @@ package com.facebook.react.uimanager;
|
||||
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.systrace.SystraceMessage;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -35,7 +35,10 @@ import javax.annotation.Nullable;
|
||||
/* package */ static Map<String, Object> createConstants(
|
||||
UIManagerModule.ViewManagerResolver resolver) {
|
||||
Map<String, Object> constants = UIManagerModuleConstants.getConstants();
|
||||
constants.put("ViewManagerNames", resolver.getViewManagerNames());
|
||||
if (!ReactFeatureFlags.lazilyLoadViewManagers) {
|
||||
constants.put("ViewManagerNames", resolver.getViewManagerNames());
|
||||
}
|
||||
constants.put("LazyViewManagersEnabled", true);
|
||||
return constants;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user