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

change JSONObject(Map) constructor to use the default capacity when a null map is passed

This commit is contained in:
John J. Aylward 2017-06-08 12:18:04 -04:00
parent 3645f91b55
commit 2fbe4d96cf

View file

@ -250,8 +250,10 @@ public class JSONObject {
* the JSONObject. * the JSONObject.
*/ */
public JSONObject(Map<?, ?> m) { public JSONObject(Map<?, ?> m) {
this.map = new HashMap<String, Object>(m == null ? 0 : m.size()); if (m == null) {
if (m != null) { this.map = new HashMap<String, Object>();
} else {
this.map = new HashMap<String, Object>(m.size());
for (final Entry<?, ?> e : m.entrySet()) { for (final Entry<?, ?> e : m.entrySet()) {
final Object value = e.getValue(); final Object value = e.getValue();
if (value != null) { if (value != null) {