From 1c1d7006c2df3509aaef871cfcfeb5c77fd58884 Mon Sep 17 00:00:00 2001 From: Andy Street Date: Tue, 5 Jan 2016 04:57:51 -0800 Subject: [PATCH] Remove extra JSUnprotect call Summary: public Value doesn't protect it's value, so it shouldn't be unprotecting them in its destructor. I'm also pretty sure we don't need to Protect the exception while it's on the stack according to the JSValueProtect docs: https://developer.apple.com/library/mac/documentation/JavaScriptCore/Reference/JSValueRef_header_reference/index.html#//apple_ref/c/func/JSValueProtect Reviewed By: lexs Differential Revision: D2779255 fb-gh-sync-id: 7d5df34639c8e7c41e92d3b8d652b93443d194a1 --- ReactAndroid/src/main/jni/react/JSCExecutor.cpp | 2 -- ReactAndroid/src/main/jni/react/Value.cpp | 7 ------- ReactAndroid/src/main/jni/react/Value.h | 1 - 3 files changed, 10 deletions(-) diff --git a/ReactAndroid/src/main/jni/react/JSCExecutor.cpp b/ReactAndroid/src/main/jni/react/JSCExecutor.cpp index b12021d41..a657a72f1 100644 --- a/ReactAndroid/src/main/jni/react/JSCExecutor.cpp +++ b/ReactAndroid/src/main/jni/react/JSCExecutor.cpp @@ -86,7 +86,6 @@ static std::string executeJSCallWithJSC( "__fbBatchedBridge.", methodName, ".apply(null, ", folly::toJson(jsonArgs), ")"); auto result = evaluateScript(ctx, String(js.c_str()), nullptr); - JSValueProtect(ctx, result); return Value(ctx, result).toJSONString(); } @@ -247,7 +246,6 @@ static JSValueRef nativeFlushQueueImmediate( return JSValueMakeUndefined(ctx); } - JSValueProtect(ctx, arguments[0]); std::string resStr = Value(ctx, arguments[0]).toJSONString(); executor->flushQueueImmediate(resStr); diff --git a/ReactAndroid/src/main/jni/react/Value.cpp b/ReactAndroid/src/main/jni/react/Value.cpp index 0859ca452..0acbc38c8 100644 --- a/ReactAndroid/src/main/jni/react/Value.cpp +++ b/ReactAndroid/src/main/jni/react/Value.cpp @@ -23,12 +23,6 @@ Value::Value(Value&& other) : other.m_value = nullptr; } -Value::~Value() { - if (m_value) { - JSValueUnprotect(m_context, m_value); - } -} - JSContextRef Value::context() const { return m_context; } @@ -37,7 +31,6 @@ std::string Value::toJSONString(unsigned indent) const { JSValueRef exn; auto stringToAdopt = JSValueCreateJSONString(m_context, m_value, indent, &exn); if (stringToAdopt == nullptr) { - JSValueProtect(m_context, exn); std::string exceptionText = Value(m_context, exn).toString().str(); throwJSExecutionException("Exception creating JSON string: %s", exceptionText.c_str()); } diff --git a/ReactAndroid/src/main/jni/react/Value.h b/ReactAndroid/src/main/jni/react/Value.h index c237bda18..8a845ebfe 100644 --- a/ReactAndroid/src/main/jni/react/Value.h +++ b/ReactAndroid/src/main/jni/react/Value.h @@ -142,7 +142,6 @@ class Value : public noncopyable { public: Value(JSContextRef context, JSValueRef value); Value(Value&&); - ~Value(); operator JSValueRef() const { return m_value;