Skip to content

Commit 55ca500

Browse files
Gaspard Petitjyemin
andcommitted
Adding BsonArray constructor that allocates an ArrayList with known capacity
JAVA-3613 Signed-off-by: Gaspard Petit <[email protected]> Co-authored-by: Jeff Yemin <[email protected]>
1 parent 661985c commit 55ca500

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bson/src/main/org/bson/BsonArray.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ public BsonArray() {
5252
this(new ArrayList<BsonValue>(), false);
5353
}
5454

55+
/**
56+
* Construct an empty BsonArray with the specified initial capacity.
57+
*
58+
* @param initialCapacity the initial capacity of the BsonArray
59+
* @throws IllegalArgumentException if the specified initial capacity
60+
* is negative
61+
* @since 4.3
62+
*/
63+
public BsonArray(final int initialCapacity) {
64+
this(new ArrayList<BsonValue>(initialCapacity), false);
65+
}
66+
5567
@SuppressWarnings("unchecked")
5668
BsonArray(final List<? extends BsonValue> values, final boolean copy) {
5769
if (copy) {

0 commit comments

Comments
 (0)