Permalink
Browse files

Remove terrible ReadableNativeArray::getMap() hack

Reviewed By: mhorowitz

Differential Revision: D3753952

fbshipit-source-id: c8ea693d3a24adad9f907ad28b811cf69ab9e68d
  • Loading branch information...
1 parent d8b2bab commit 9a5d3bacb99275e952619ab142f4381008d13d89 @cjhopman cjhopman committed with Facebook Github Bot 4 Aug 23, 2016
@@ -11,6 +11,7 @@
#include "JCallback.h"
#include "JExecutorToken.h"
#include "ReadableNativeArray.h"
+#include "ReadableNativeMap.h"
namespace facebook {
namespace react {
@@ -144,8 +145,7 @@ jvalue extract(std::weak_ptr<Instance>& instance, ExecutorToken token, char type
value.l = ReadableNativeArray::newObjectCxxArgs(arg).release();
break;
case 'M':
- // HACK: Workaround for constructing ReadableNativeMap
- value.l = ExposedReadableNativeArray(folly::dynamic::array(arg)).getMap(0).release();
+ value.l = ReadableNativeMap::newObjectCxxArgs(arg).release();
break;
case 'X':
value.l = extractCallback(instance, token, arg).release();
@@ -76,11 +76,9 @@ local_ref<ReadableType> ReadableNativeArray::getType(jint index) {
return ReadableType::getType(array.at(index).type());
}
-// Export getMap() so we can workaround constructing ReadableNativeMap
-__attribute__((visibility("default")))
local_ref<NativeMap::jhybridobject> ReadableNativeArray::getMap(jint index) {
- // TODO(cjhopman): ... this moves the map?!?
- return ReadableNativeMap::createWithContents(std::move(array.at(index)));
+ auto& elem = array.at(index);
+ return ReadableNativeMap::createWithContents(folly::dynamic(elem));
}
namespace {

1 comment on commit 9a5d3ba

@shexiaoheng

👍

Please sign in to comment.