From 9ff4d31dc4e1c1617c19408920df486ddbb112c7 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 16 Sep 2016 06:14:15 -0700 Subject: [PATCH] Remove unnecessary JSContextGetGlobalContext call Reviewed By: majak, alexeylang Differential Revision: D3871178 fbshipit-source-id: 4a6dff7cce233e9bc2e2a80858774a2e6af6b67d --- React/Executors/RCTJSCExecutor.mm | 5 ++--- React/Executors/RCTJSCWrapper.h | 6 ------ React/Executors/RCTJSCWrapper.mm | 6 ------ 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/React/Executors/RCTJSCExecutor.mm b/React/Executors/RCTJSCExecutor.mm index 36dbc57ed7..c8f6702c36 100644 --- a/React/Executors/RCTJSCExecutor.mm +++ b/React/Executors/RCTJSCExecutor.mm @@ -582,15 +582,14 @@ static void installBasicSynchronousHooksOnContext(JSContext *context) RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper; JSContext *context = strongSelf->_context.context; - JSGlobalContextRef ctx = context.JSGlobalContextRef; - JSGlobalContextRef contextJSRef = jscWrapper->JSContextGetGlobalContext(ctx); + JSGlobalContextRef contextJSRef = context.JSGlobalContextRef; // get the BatchedBridge object JSValueRef errorJSRef = NULL; JSValueRef batchedBridgeRef = strongSelf->_batchedBridgeRef; if (!batchedBridgeRef) { JSStringRef moduleNameJSStringRef = jscWrapper->JSStringCreateWithUTF8CString("__fbBatchedBridge"); - JSObjectRef globalObjectJSRef = jscWrapper->JSContextGetGlobalObject(ctx); + JSObjectRef globalObjectJSRef = jscWrapper->JSContextGetGlobalObject(contextJSRef); batchedBridgeRef = jscWrapper->JSObjectGetProperty(contextJSRef, globalObjectJSRef, moduleNameJSStringRef, &errorJSRef); jscWrapper->JSStringRelease(moduleNameJSStringRef); strongSelf->_batchedBridgeRef = batchedBridgeRef; diff --git a/React/Executors/RCTJSCWrapper.h b/React/Executors/RCTJSCWrapper.h index 612b457776..7ae6f0b2ba 100644 --- a/React/Executors/RCTJSCWrapper.h +++ b/React/Executors/RCTJSCWrapper.h @@ -11,13 +11,10 @@ #import "RCTDefines.h" -typedef JSStringRef (*JSValueToStringCopyFuncType)(JSContextRef, JSValueRef, JSValueRef *); typedef JSStringRef (*JSStringCreateWithCFStringFuncType)(CFStringRef); -typedef CFStringRef (*JSStringCopyCFStringFuncType)(CFAllocatorRef, JSStringRef); typedef JSStringRef (*JSStringCreateWithUTF8CStringFuncType)(const char *); typedef void (*JSStringReleaseFuncType)(JSStringRef); typedef void (*JSGlobalContextSetNameFuncType)(JSGlobalContextRef, JSStringRef); -typedef JSGlobalContextRef (*JSContextGetGlobalContextFuncType)(JSContextRef); typedef void (*JSObjectSetPropertyFuncType)(JSContextRef, JSObjectRef, JSStringRef, JSValueRef, JSPropertyAttributes, JSValueRef *); typedef JSObjectRef (*JSContextGetGlobalObjectFuncType)(JSContextRef); 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 struct RCTJSCWrapper { - JSValueToStringCopyFuncType JSValueToStringCopy; JSStringCreateWithCFStringFuncType JSStringCreateWithCFString; - JSStringCopyCFStringFuncType JSStringCopyCFString; JSStringCreateWithUTF8CStringFuncType JSStringCreateWithUTF8CString; JSStringReleaseFuncType JSStringRelease; JSGlobalContextSetNameFuncType JSGlobalContextSetName; - JSContextGetGlobalContextFuncType JSContextGetGlobalContext; JSObjectSetPropertyFuncType JSObjectSetProperty; JSContextGetGlobalObjectFuncType JSContextGetGlobalObject; JSObjectGetPropertyFuncType JSObjectGetProperty; diff --git a/React/Executors/RCTJSCWrapper.mm b/React/Executors/RCTJSCWrapper.mm index 0a736df2b2..27c534843a 100644 --- a/React/Executors/RCTJSCWrapper.mm +++ b/React/Executors/RCTJSCWrapper.mm @@ -44,13 +44,10 @@ static void *RCTCustomLibraryHandler(void) static void RCTSetUpSystemLibraryPointers(RCTJSCWrapper *wrapper) { - wrapper->JSValueToStringCopy = JSValueToStringCopy; wrapper->JSStringCreateWithCFString = JSStringCreateWithCFString; - wrapper->JSStringCopyCFString = JSStringCopyCFString; wrapper->JSStringCreateWithUTF8CString = JSStringCreateWithUTF8CString; wrapper->JSStringRelease = JSStringRelease; wrapper->JSGlobalContextSetName = JSGlobalContextSetName; - wrapper->JSContextGetGlobalContext = JSContextGetGlobalContext; wrapper->JSObjectSetProperty = JSObjectSetProperty; wrapper->JSContextGetGlobalObject = JSContextGetGlobalObject; wrapper->JSObjectGetProperty = JSObjectGetProperty; @@ -74,13 +71,10 @@ static void RCTSetUpCustomLibraryPointers(RCTJSCWrapper *wrapper) return; } - wrapper->JSValueToStringCopy = (JSValueToStringCopyFuncType)dlsym(libraryHandle, "JSValueToStringCopy"); wrapper->JSStringCreateWithCFString = (JSStringCreateWithCFStringFuncType)dlsym(libraryHandle, "JSStringCreateWithCFString"); - wrapper->JSStringCopyCFString = (JSStringCopyCFStringFuncType)dlsym(libraryHandle, "JSStringCopyCFString"); wrapper->JSStringCreateWithUTF8CString = (JSStringCreateWithUTF8CStringFuncType)dlsym(libraryHandle, "JSStringCreateWithUTF8CString"); wrapper->JSStringRelease = (JSStringReleaseFuncType)dlsym(libraryHandle, "JSStringRelease"); wrapper->JSGlobalContextSetName = (JSGlobalContextSetNameFuncType)dlsym(libraryHandle, "JSGlobalContextSetName"); - wrapper->JSContextGetGlobalContext = (JSContextGetGlobalContextFuncType)dlsym(libraryHandle, "JSContextGetGlobalContext"); wrapper->JSObjectSetProperty = (JSObjectSetPropertyFuncType)dlsym(libraryHandle, "JSObjectSetProperty"); wrapper->JSContextGetGlobalObject = (JSContextGetGlobalObjectFuncType)dlsym(libraryHandle, "JSContextGetGlobalObject"); wrapper->JSObjectGetProperty = (JSObjectGetPropertyFuncType)dlsym(libraryHandle, "JSObjectGetProperty");