From 1e6f5344d66808b413146017b3f49fbd40dbcdf8 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Thu, 31 Jan 2019 16:54:37 -0800 Subject: [PATCH] avoid double lookup of a nativemodule when resolving turbomodule Summary: A simple optimization to not access `NativeModules` property twice. Reviewed By: RSNara Differential Revision: D13908128 fbshipit-source-id: d41cd5f855fb0176170d6bdc3ac93df5593eeca5 --- Libraries/TurboModule/TurboModuleRegistry.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/TurboModule/TurboModuleRegistry.js b/Libraries/TurboModule/TurboModuleRegistry.js index 54afa00af..a31f736d7 100644 --- a/Libraries/TurboModule/TurboModuleRegistry.js +++ b/Libraries/TurboModule/TurboModuleRegistry.js @@ -17,8 +17,9 @@ import {NativeModules} from 'react-native'; // TODO function get(name: string): ?T { // Backward compatibility layer during migration. - if (NativeModules[name] != null) { - return ((NativeModules[name]: any): T); + const legacyModule = NativeModules[name]; + if (legacyModule != null) { + return ((legacyModule: any): T); } const module: ?T = global.__turboModuleProxy(name);