Remove unnecessary JSContextGetGlobalContext call

Reviewed By: majak, alexeylang

Differential Revision: D3871178

fbshipit-source-id: 4a6dff7cce233e9bc2e2a80858774a2e6af6b67d
This commit is contained in:
Pieter De Baets 2016-09-16 06:14:15 -07:00 committed by Facebook Github Bot 9
parent 228f104dad
commit 9ff4d31dc4
3 changed files with 2 additions and 15 deletions

View File

@ -582,15 +582,14 @@ static void installBasicSynchronousHooksOnContext(JSContext *context)
RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper; RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper;
JSContext *context = strongSelf->_context.context; JSContext *context = strongSelf->_context.context;
JSGlobalContextRef ctx = context.JSGlobalContextRef; JSGlobalContextRef contextJSRef = context.JSGlobalContextRef;
JSGlobalContextRef contextJSRef = jscWrapper->JSContextGetGlobalContext(ctx);
// get the BatchedBridge object // get the BatchedBridge object
JSValueRef errorJSRef = NULL; JSValueRef errorJSRef = NULL;
JSValueRef batchedBridgeRef = strongSelf->_batchedBridgeRef; JSValueRef batchedBridgeRef = strongSelf->_batchedBridgeRef;
if (!batchedBridgeRef) { if (!batchedBridgeRef) {
JSStringRef moduleNameJSStringRef = jscWrapper->JSStringCreateWithUTF8CString("__fbBatchedBridge"); JSStringRef moduleNameJSStringRef = jscWrapper->JSStringCreateWithUTF8CString("__fbBatchedBridge");
JSObjectRef globalObjectJSRef = jscWrapper->JSContextGetGlobalObject(ctx); JSObjectRef globalObjectJSRef = jscWrapper->JSContextGetGlobalObject(contextJSRef);
batchedBridgeRef = jscWrapper->JSObjectGetProperty(contextJSRef, globalObjectJSRef, moduleNameJSStringRef, &errorJSRef); batchedBridgeRef = jscWrapper->JSObjectGetProperty(contextJSRef, globalObjectJSRef, moduleNameJSStringRef, &errorJSRef);
jscWrapper->JSStringRelease(moduleNameJSStringRef); jscWrapper->JSStringRelease(moduleNameJSStringRef);
strongSelf->_batchedBridgeRef = batchedBridgeRef; strongSelf->_batchedBridgeRef = batchedBridgeRef;

View File

@ -11,13 +11,10 @@
#import "RCTDefines.h" #import "RCTDefines.h"
typedef JSStringRef (*JSValueToStringCopyFuncType)(JSContextRef, JSValueRef, JSValueRef *);
typedef JSStringRef (*JSStringCreateWithCFStringFuncType)(CFStringRef); typedef JSStringRef (*JSStringCreateWithCFStringFuncType)(CFStringRef);
typedef CFStringRef (*JSStringCopyCFStringFuncType)(CFAllocatorRef, JSStringRef);
typedef JSStringRef (*JSStringCreateWithUTF8CStringFuncType)(const char *); typedef JSStringRef (*JSStringCreateWithUTF8CStringFuncType)(const char *);
typedef void (*JSStringReleaseFuncType)(JSStringRef); typedef void (*JSStringReleaseFuncType)(JSStringRef);
typedef void (*JSGlobalContextSetNameFuncType)(JSGlobalContextRef, JSStringRef); typedef void (*JSGlobalContextSetNameFuncType)(JSGlobalContextRef, JSStringRef);
typedef JSGlobalContextRef (*JSContextGetGlobalContextFuncType)(JSContextRef);
typedef void (*JSObjectSetPropertyFuncType)(JSContextRef, JSObjectRef, JSStringRef, JSValueRef, JSPropertyAttributes, JSValueRef *); typedef void (*JSObjectSetPropertyFuncType)(JSContextRef, JSObjectRef, JSStringRef, JSValueRef, JSPropertyAttributes, JSValueRef *);
typedef JSObjectRef (*JSContextGetGlobalObjectFuncType)(JSContextRef); typedef JSObjectRef (*JSContextGetGlobalObjectFuncType)(JSContextRef);
typedef JSValueRef (*JSObjectGetPropertyFuncType)(JSContextRef, JSObjectRef, JSStringRef, JSValueRef *); typedef JSValueRef (*JSObjectGetPropertyFuncType)(JSContextRef, JSObjectRef, JSStringRef, JSValueRef *);
@ -31,13 +28,10 @@ typedef JSValueRef (*JSEvaluateScriptFuncType)(JSContextRef, JSStringRef, JSObje
typedef void (*configureJSContextForIOSFuncType)(JSContextRef ctx, const char *cacheDir); typedef void (*configureJSContextForIOSFuncType)(JSContextRef ctx, const char *cacheDir);
typedef struct RCTJSCWrapper { typedef struct RCTJSCWrapper {
JSValueToStringCopyFuncType JSValueToStringCopy;
JSStringCreateWithCFStringFuncType JSStringCreateWithCFString; JSStringCreateWithCFStringFuncType JSStringCreateWithCFString;
JSStringCopyCFStringFuncType JSStringCopyCFString;
JSStringCreateWithUTF8CStringFuncType JSStringCreateWithUTF8CString; JSStringCreateWithUTF8CStringFuncType JSStringCreateWithUTF8CString;
JSStringReleaseFuncType JSStringRelease; JSStringReleaseFuncType JSStringRelease;
JSGlobalContextSetNameFuncType JSGlobalContextSetName; JSGlobalContextSetNameFuncType JSGlobalContextSetName;
JSContextGetGlobalContextFuncType JSContextGetGlobalContext;
JSObjectSetPropertyFuncType JSObjectSetProperty; JSObjectSetPropertyFuncType JSObjectSetProperty;
JSContextGetGlobalObjectFuncType JSContextGetGlobalObject; JSContextGetGlobalObjectFuncType JSContextGetGlobalObject;
JSObjectGetPropertyFuncType JSObjectGetProperty; JSObjectGetPropertyFuncType JSObjectGetProperty;

View File

@ -44,13 +44,10 @@ static void *RCTCustomLibraryHandler(void)
static void RCTSetUpSystemLibraryPointers(RCTJSCWrapper *wrapper) static void RCTSetUpSystemLibraryPointers(RCTJSCWrapper *wrapper)
{ {
wrapper->JSValueToStringCopy = JSValueToStringCopy;
wrapper->JSStringCreateWithCFString = JSStringCreateWithCFString; wrapper->JSStringCreateWithCFString = JSStringCreateWithCFString;
wrapper->JSStringCopyCFString = JSStringCopyCFString;
wrapper->JSStringCreateWithUTF8CString = JSStringCreateWithUTF8CString; wrapper->JSStringCreateWithUTF8CString = JSStringCreateWithUTF8CString;
wrapper->JSStringRelease = JSStringRelease; wrapper->JSStringRelease = JSStringRelease;
wrapper->JSGlobalContextSetName = JSGlobalContextSetName; wrapper->JSGlobalContextSetName = JSGlobalContextSetName;
wrapper->JSContextGetGlobalContext = JSContextGetGlobalContext;
wrapper->JSObjectSetProperty = JSObjectSetProperty; wrapper->JSObjectSetProperty = JSObjectSetProperty;
wrapper->JSContextGetGlobalObject = JSContextGetGlobalObject; wrapper->JSContextGetGlobalObject = JSContextGetGlobalObject;
wrapper->JSObjectGetProperty = JSObjectGetProperty; wrapper->JSObjectGetProperty = JSObjectGetProperty;
@ -74,13 +71,10 @@ static void RCTSetUpCustomLibraryPointers(RCTJSCWrapper *wrapper)
return; return;
} }
wrapper->JSValueToStringCopy = (JSValueToStringCopyFuncType)dlsym(libraryHandle, "JSValueToStringCopy");
wrapper->JSStringCreateWithCFString = (JSStringCreateWithCFStringFuncType)dlsym(libraryHandle, "JSStringCreateWithCFString"); wrapper->JSStringCreateWithCFString = (JSStringCreateWithCFStringFuncType)dlsym(libraryHandle, "JSStringCreateWithCFString");
wrapper->JSStringCopyCFString = (JSStringCopyCFStringFuncType)dlsym(libraryHandle, "JSStringCopyCFString");
wrapper->JSStringCreateWithUTF8CString = (JSStringCreateWithUTF8CStringFuncType)dlsym(libraryHandle, "JSStringCreateWithUTF8CString"); wrapper->JSStringCreateWithUTF8CString = (JSStringCreateWithUTF8CStringFuncType)dlsym(libraryHandle, "JSStringCreateWithUTF8CString");
wrapper->JSStringRelease = (JSStringReleaseFuncType)dlsym(libraryHandle, "JSStringRelease"); wrapper->JSStringRelease = (JSStringReleaseFuncType)dlsym(libraryHandle, "JSStringRelease");
wrapper->JSGlobalContextSetName = (JSGlobalContextSetNameFuncType)dlsym(libraryHandle, "JSGlobalContextSetName"); wrapper->JSGlobalContextSetName = (JSGlobalContextSetNameFuncType)dlsym(libraryHandle, "JSGlobalContextSetName");
wrapper->JSContextGetGlobalContext = (JSContextGetGlobalContextFuncType)dlsym(libraryHandle, "JSContextGetGlobalContext");
wrapper->JSObjectSetProperty = (JSObjectSetPropertyFuncType)dlsym(libraryHandle, "JSObjectSetProperty"); wrapper->JSObjectSetProperty = (JSObjectSetPropertyFuncType)dlsym(libraryHandle, "JSObjectSetProperty");
wrapper->JSContextGetGlobalObject = (JSContextGetGlobalObjectFuncType)dlsym(libraryHandle, "JSContextGetGlobalObject"); wrapper->JSContextGetGlobalObject = (JSContextGetGlobalObjectFuncType)dlsym(libraryHandle, "JSContextGetGlobalObject");
wrapper->JSObjectGetProperty = (JSObjectGetPropertyFuncType)dlsym(libraryHandle, "JSObjectGetProperty"); wrapper->JSObjectGetProperty = (JSObjectGetPropertyFuncType)dlsym(libraryHandle, "JSObjectGetProperty");