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:
parent
9c092753b0
commit
3645f91b55
1 changed files with 4 additions and 2 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue