Skip to content

Commit 86e136a

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

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ private void addAll(Collection<?> collection) {
15481548
private void addAll(Object array) throws JSONException {
15491549
if (array.getClass().isArray()) {
15501550
int length = Array.getLength(array);
1551-
this.myArrayList.ensureCapacity(length);
1551+
this.myArrayList.ensureCapacity(this.myArrayList.size() + length);
15521552
for (int i = 0; i < length; i += 1) {
15531553
this.put(JSONObject.wrap(Array.get(array, i)));
15541554
}

0 commit comments

Comments
 (0)