From 1c692e2eb68e2006964b4397a07bb3c2a5ed4505 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Sat, 30 May 2015 13:21:42 -0700 Subject: [PATCH] [ReactNative] Use JSValueIsUndefined instead of comparing with JSValueMakeUndefined Summary: @public Use JSValueIsUndefined instead of caching an JSValueMakeUndefined to compare with as suggested in https://github.com/facebook/react-native/pull/1432#commitcomment-11437434 Test Plan: Run the RCTContextExecutor tests --- React/Executors/RCTContextExecutor.m | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/React/Executors/RCTContextExecutor.m b/React/Executors/RCTContextExecutor.m index f585edc10f283e..3a220873952664 100644 --- a/React/Executors/RCTContextExecutor.m +++ b/React/Executors/RCTContextExecutor.m @@ -66,7 +66,6 @@ @implementation RCTContextExecutor { RCTJavaScriptContext *_context; NSThread *_javaScriptThread; - JSValueRef _undefined; } /** @@ -238,9 +237,6 @@ - (instancetype)initWithJavaScriptThread:(NSThread *)javaScriptThread JSContextGroupRelease(group); } - // Constant value used for comparison - _undefined = JSValueMakeUndefined(ctx); - strongSelf->_context = [[RCTJavaScriptContext alloc] initWithJSContext:ctx]; [strongSelf _addNativeHook:RCTNativeLoggingHook withName:"nativeLoggingHook"]; [strongSelf _addNativeHook:RCTNoop withName:"noop"]; @@ -312,7 +308,7 @@ - (void)executeJSCall:(NSString *)name JSValueRef requireJSRef = JSObjectGetProperty(contextJSRef, globalObjectJSRef, requireNameJSStringRef, &errorJSRef); JSStringRelease(requireNameJSStringRef); - if (requireJSRef != NULL && requireJSRef != _undefined && errorJSRef == NULL) { + if (requireJSRef != NULL && !JSValueIsUndefined(contextJSRef, requireJSRef) && errorJSRef == NULL) { // get module JSStringRef moduleNameJSStringRef = JSStringCreateWithCFString((__bridge CFStringRef)name);