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
This commit is contained in:
parent
3507bc61a5
commit
1c1d7006c2
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -142,7 +142,6 @@ class Value : public noncopyable {
|
|||
public:
|
||||
Value(JSContextRef context, JSValueRef value);
|
||||
Value(Value&&);
|
||||
~Value();
|
||||
|
||||
operator JSValueRef() const {
|
||||
return m_value;
|
||||
|
|
Loading…
Reference in New Issue