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 коммит произвёл Facebook Github Bot 9
Родитель 228f104dad
Коммит 9ff4d31dc4
3 изменённых файлов: 2 добавлений и 15 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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");