Skip to content

Commit

Permalink
Initialize internals of ReadableNativeMap with the correct initial ca…
Browse files Browse the repository at this point in the history
…pacity

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

Reviewed By: kathryngray

Differential Revision: D13970989

fbshipit-source-id: d104fcbaf938f377a0138b839375c4bc146f1732
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 6, 2019
1 parent aa3fc09 commit 185320d
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ private HashMap<String,Object> getLocalMap() {
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]);
}
}
Expand All @@ -80,8 +81,9 @@ private HashMap<String,ReadableType> getLocalTypeMap() {
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]);
}
}
Expand Down

0 comments on commit 185320d

Please sign in to comment.