Skip to content

Commit 1528bdd

Browse files
committed
slight optimization of ValueFactory.newMap
1 parent d2a2247 commit 1528bdd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

msgpack-core/src/main/java/org/msgpack/value/ValueFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,12 @@ public static ImmutableMapValue emptyMap()
233233

234234
public static MapValue newMap(Map.Entry<? extends Value, ? extends Value>... pairs)
235235
{
236-
MapBuilder b = new MapBuilder();
237-
for (Map.Entry<? extends Value, ? extends Value> p : pairs) {
238-
b.put(p);
236+
Value[] kvs = new Value[pairs.length * 2];
237+
for (int i=0; i < pairs.length; i += 2) {
238+
kvs[i * 2] = pairs[i].getKey();
239+
kvs[i * 2 + 1] = pairs[i].getValue();
239240
}
240-
return b.build();
241+
return newMap(kvs, true);
241242
}
242243

243244
public static MapBuilder newMapBuilder()

0 commit comments

Comments
 (0)