mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 19:35:31 -04:00
Increase array list capacity in addAll method to ensure it can hold additional elements.
This commit is contained in:
parent
aa0a5a7245
commit
86e136afc9
@ -1548,7 +1548,7 @@ public class JSONArray implements Iterable<Object> {
|
||||
private void addAll(Object array) throws JSONException {
|
||||
if (array.getClass().isArray()) {
|
||||
int length = Array.getLength(array);
|
||||
this.myArrayList.ensureCapacity(length);
|
||||
this.myArrayList.ensureCapacity(this.myArrayList.size() + length);
|
||||
for (int i = 0; i < length; i += 1) {
|
||||
this.put(JSONObject.wrap(Array.get(array, i)));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user