Skip to content

Commit

Permalink
Remove release from ReadableNativeArray and Map
Browse files Browse the repository at this point in the history
Reviewed By: mhorowitz

Differential Revision: D6846268

fbshipit-source-id: 2f750a05ee63a744e7f64b3fe67736df3614ef3d
  • Loading branch information
Kathy Gray authored and facebook-github-bot committed Feb 1, 2018
1 parent 88980f2 commit 28be33a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
15 changes: 5 additions & 10 deletions ReactAndroid/src/main/jni/react/jni/ReadableNativeArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,24 @@ local_ref<JArrayClass<jobject>> ReadableNativeArray::importArray() {
break;
}
case folly::dynamic::Type::BOOL: {
jarray->
setElement(i,
JBoolean::valueOf(ReadableNativeArray::getBoolean(i)).release());
(*jarray)[i] = JBoolean::valueOf(ReadableNativeArray::getBoolean(i));
break;
}
case folly::dynamic::Type::INT64:
case folly::dynamic::Type::DOUBLE: {
jarray->setElement(i,
JDouble::valueOf(ReadableNativeArray::getDouble(i)).release());
(*jarray)[i] = JDouble::valueOf(ReadableNativeArray::getDouble(i));
break;
}
case folly::dynamic::Type::STRING: {
jarray->
setElement(i,
make_jstring(ReadableNativeArray::getString(i)).release());
(*jarray)[i] = make_jstring(ReadableNativeArray::getString(i));
break;
}
case folly::dynamic::Type::OBJECT: {
jarray->setElement(i,ReadableNativeArray::getMap(i).release());
(*jarray)[i] = ReadableNativeArray::getMap(i);
break;
}
case folly::dynamic::Type::ARRAY: {
jarray->setElement(i,ReadableNativeArray::getArray(i).release());
(*jarray)[i] = ReadableNativeArray::getArray(i);
break;
}
default:
Expand Down
21 changes: 9 additions & 12 deletions ReactAndroid/src/main/jni/react/jni/ReadableNativeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local_ref<JArrayClass<jstring>> ReadableNativeMap::importKeys() {
jint size = keys_.value().size();
auto jarray = JArrayClass<jstring>::newArray(size);
for (jint i = 0; i < size; i++) {
jarray->setElement(i, make_jstring(keys_.value()[i].getString().c_str()).release());
(*jarray)[i] = make_jstring(keys_.value()[i].getString());
}
return jarray;
}
Expand All @@ -43,29 +43,26 @@ local_ref<JArrayClass<jobject>> ReadableNativeMap::importValues() {
break;
}
case folly::dynamic::Type::BOOL: {
jarray->
setElement(i,
JBoolean::valueOf(ReadableNativeMap::getBooleanKey(key)).release());
(*jarray)[i] =
JBoolean::valueOf(ReadableNativeMap::getBooleanKey(key));
break;
}
case folly::dynamic::Type::INT64:
case folly::dynamic::Type::DOUBLE: {
jarray->setElement(i,
JDouble::valueOf(ReadableNativeMap::getDoubleKey(key)).release());
(*jarray)[i] =
JDouble::valueOf(ReadableNativeMap::getDoubleKey(key));
break;
}
case folly::dynamic::Type::STRING: {
jarray->
setElement(i,
ReadableNativeMap::getStringKey(key).release());
(*jarray)[i] = ReadableNativeMap::getStringKey(key);
break;
}
case folly::dynamic::Type::OBJECT: {
jarray->setElement(i,ReadableNativeMap::getMapKey(key).release());
(*jarray)[i] = ReadableNativeMap::getMapKey(key);
break;
}
case folly::dynamic::Type::ARRAY: {
jarray->setElement(i,ReadableNativeMap::getArrayKey(key).release());
(*jarray)[i] = ReadableNativeMap::getArrayKey(key);
break;
}
default: {
Expand All @@ -82,7 +79,7 @@ local_ref<JArrayClass<jobject>> ReadableNativeMap::importTypes() {
auto jarray = JArrayClass<jobject>::newArray(size);
for (jint i = 0; i < size; i++) {
std::string key = keys_.value()[i].getString().c_str();
jarray->setElement(i, ReadableNativeMap::getValueType(key).release());
(*jarray)[i] = ReadableNativeMap::getValueType(key);
}
return jarray;
}
Expand Down

0 comments on commit 28be33a

Please sign in to comment.