mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 16:00:51 -07:00
Increase array list capacity in addAll(collection) method to ensure it can hold additional elements.
This commit is contained in:
parent
86e136afc9
commit
f1d354ce7b
1 changed files with 1 additions and 0 deletions
|
@ -1528,6 +1528,7 @@ public class JSONArray implements Iterable<Object> {
|
||||||
* A Collection.
|
* A Collection.
|
||||||
*/
|
*/
|
||||||
private void addAll(Collection<?> collection) {
|
private void addAll(Collection<?> collection) {
|
||||||
|
this.myArrayList.ensureCapacity(this.myArrayList.size() + collection.size());
|
||||||
for (Object o: collection){
|
for (Object o: collection){
|
||||||
this.myArrayList.add(JSONObject.wrap(o));
|
this.myArrayList.add(JSONObject.wrap(o));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue