Skip to content

Commit f1d354c

Browse files
committed
Increase array list capacity in addAll(collection) method to ensure it can hold additional elements.
1 parent 86e136a commit f1d354c

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/main/java/org/json/JSONArray.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,7 @@ public boolean isEmpty() {
15281528
* A Collection.
15291529
*/
15301530
private void addAll(Collection<?> collection) {
1531+
this.myArrayList.ensureCapacity(this.myArrayList.size() + collection.size());
15311532
for (Object o: collection){
15321533
this.myArrayList.add(JSONObject.wrap(o));
15331534
}

0 commit comments

Comments
 (0)