Initialize internals of ReadableNativeMap with the correct initial capacity

Summary: This diff initializes internals maps of ReadableNativeMap with the correct initial capacity

Reviewed By: kathryngray

Differential Revision: D13970989

fbshipit-source-id: d104fcbaf938f377a0138b839375c4bc146f1732
This commit is contained in:
David Vacca
2019-02-06 09:20:56 -08:00
committed by Facebook Github Bot
parent aa3fc0910a
commit 185320db23

View File

@@ -54,8 +54,9 @@ public class ReadableNativeMap extends NativeMap implements ReadableMap {
if (mLocalMap == null) {
Object[] values = Assertions.assertNotNull(importValues());
mJniCallCounter++;
mLocalMap = new HashMap<>();
for(int i = 0; i< mKeys.length; i++) {
int length = mKeys.length;
mLocalMap = new HashMap<>(length);
for(int i = 0; i< length; i++) {
mLocalMap.put(mKeys[i], values[i]);
}
}
@@ -80,8 +81,9 @@ public class ReadableNativeMap extends NativeMap implements ReadableMap {
if (mLocalTypeMap == null) {
Object[] types = Assertions.assertNotNull(importTypes());
mJniCallCounter++;
mLocalTypeMap = new HashMap<>();
for(int i = 0; i< mKeys.length; i++) {
int length = mKeys.length;
mLocalTypeMap = new HashMap<>(length);
for(int i = 0; i< length; i++) {
mLocalTypeMap.put(mKeys[i], (ReadableType) types[i]);
}
}