1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

change JSONArray(Collection) constructor to use the default capacity when a null collection is passed

This commit is contained in:
John J. Aylward 2017-06-08 12:15:03 -04:00
parent 9c092753b0
commit 3645f91b55

View file

@ -154,8 +154,10 @@ public class JSONArray implements Iterable<Object> {
* A Collection.
*/
public JSONArray(Collection<?> collection) {
this.myArrayList = new ArrayList<Object>(collection == null ? 0 : collection.size());
if (collection != null) {
if (collection == null) {
this.myArrayList = new ArrayList<Object>();
} else {
this.myArrayList = new ArrayList<Object>(collection.size());
for (Object o: collection){
this.myArrayList.add(JSONObject.wrap(o));
}