From bf51a9faf9942571cf1eea64ae260a9ced5c4598 Mon Sep 17 00:00:00 2001 From: Beluga Behr Date: Sun, 30 Dec 2018 20:34:13 -0500 Subject: [PATCH] THRIFT-4695: Pre-Size Java Collections in Union --- lib/java/src/org/apache/thrift/TUnion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/java/src/org/apache/thrift/TUnion.java b/lib/java/src/org/apache/thrift/TUnion.java index 13f9c6774..1ef11df49 100644 --- a/lib/java/src/org/apache/thrift/TUnion.java +++ b/lib/java/src/org/apache/thrift/TUnion.java @@ -79,7 +79,7 @@ public abstract class TUnion, F extends TFieldIdEnum> impl } private static Map deepCopyMap(Map map) { - Map copy = new HashMap(); + Map copy = new HashMap(map.size()); for (Map.Entry entry : map.entrySet()) { copy.put(deepCopyObject(entry.getKey()), deepCopyObject(entry.getValue())); } @@ -87,7 +87,7 @@ public abstract class TUnion, F extends TFieldIdEnum> impl } private static Set deepCopySet(Set set) { - Set copy = new HashSet(); + Set copy = new HashSet(set.size()); for (Object o : set) { copy.add(deepCopyObject(o)); }