mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-06 10:45:23 +08:00
Increase array list capacity in addAll(collection) method to ensure it can hold additional elements.
This commit is contained in:
@@ -1528,6 +1528,7 @@ public class JSONArray implements Iterable<Object> {
|
||||
* 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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user