Skip to content

Commit

Permalink
Increase array list capacity in addAll(collection) method to ensure i…
Browse files Browse the repository at this point in the history
…t can hold additional elements.
  • Loading branch information
ethauvin committed Jul 22, 2020
1 parent 86e136a commit f1d354c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/json/JSONArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,7 @@ public boolean isEmpty() {
* A Collection.
*/
private void addAll(Collection<?> collection) {
this.myArrayList.ensureCapacity(this.myArrayList.size() + collection.size());
for (Object o: collection){
this.myArrayList.add(JSONObject.wrap(o));
}
Expand Down

0 comments on commit f1d354c

Please sign in to comment.