Skip to content

Commit f1ffad8

Browse files
committed
initialize array lists with correct size
1 parent 575535d commit f1ffad8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

api/incubator/src/main/java/io/opentelemetry/api/incubator/common/ArrayBackedExtendedAttributesBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,28 @@ private void putValue(ExtendedAttributeKey<?> key, Value<?> valueObj) {
7878
ExtendedAttributeType attributeType = attributeType(arrayValues);
7979
switch (attributeType) {
8080
case STRING_ARRAY:
81-
List<String> strings = new ArrayList<>();
81+
List<String> strings = new ArrayList<>(arrayValues.size());
8282
for (Value<?> v : arrayValues) {
8383
strings.add((String) v.getValue());
8484
}
8585
put(stringArrayKey(keyName), strings);
8686
return;
8787
case LONG_ARRAY:
88-
List<Long> longs = new ArrayList<>();
88+
List<Long> longs = new ArrayList<>(arrayValues.size());
8989
for (Value<?> v : arrayValues) {
9090
longs.add((Long) v.getValue());
9191
}
9292
put(longArrayKey(keyName), longs);
9393
return;
9494
case DOUBLE_ARRAY:
95-
List<Double> doubles = new ArrayList<>();
95+
List<Double> doubles = new ArrayList<>(arrayValues.size());
9696
for (Value<?> v : arrayValues) {
9797
doubles.add((Double) v.getValue());
9898
}
9999
put(doubleArrayKey(keyName), doubles);
100100
return;
101101
case BOOLEAN_ARRAY:
102-
List<Boolean> booleans = new ArrayList<>();
102+
List<Boolean> booleans = new ArrayList<>(arrayValues.size());
103103
for (Value<?> v : arrayValues) {
104104
booleans.add((Boolean) v.getValue());
105105
}

0 commit comments

Comments
 (0)