THRIFT-4695: Pre-Size Java Collections in Union

This commit is contained in:
Beluga Behr 2018-12-30 20:34:13 -05:00 committed by James E. King III
parent 75bac10dbd
commit bf51a9faf9

View File

@ -79,7 +79,7 @@ public abstract class TUnion<T extends TUnion<T,F>, F extends TFieldIdEnum> impl
} }
private static Map deepCopyMap(Map<Object, Object> map) { private static Map deepCopyMap(Map<Object, Object> map) {
Map copy = new HashMap(); Map copy = new HashMap(map.size());
for (Map.Entry<Object, Object> entry : map.entrySet()) { for (Map.Entry<Object, Object> entry : map.entrySet()) {
copy.put(deepCopyObject(entry.getKey()), deepCopyObject(entry.getValue())); copy.put(deepCopyObject(entry.getKey()), deepCopyObject(entry.getValue()));
} }
@ -87,7 +87,7 @@ public abstract class TUnion<T extends TUnion<T,F>, F extends TFieldIdEnum> impl
} }
private static Set deepCopySet(Set set) { private static Set deepCopySet(Set set) {
Set copy = new HashSet(); Set copy = new HashSet(set.size());
for (Object o : set) { for (Object o : set) {
copy.add(deepCopyObject(o)); copy.add(deepCopyObject(o));
} }