X Tutup
Skip to content

Commit 2fbe4d9

Browse files
author
John J. Aylward
committed
change JSONObject(Map) constructor to use the default capacity when a null map is passed
1 parent 3645f91 commit 2fbe4d9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

JSONObject.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,10 @@ public JSONObject(JSONTokener x) throws JSONException {
250250
* the JSONObject.
251251
*/
252252
public JSONObject(Map<?, ?> m) {
253-
this.map = new HashMap<String, Object>(m == null ? 0 : m.size());
254-
if (m != null) {
253+
if (m == null) {
254+
this.map = new HashMap<String, Object>();
255+
} else {
256+
this.map = new HashMap<String, Object>(m.size());
255257
for (final Entry<?, ?> e : m.entrySet()) {
256258
final Object value = e.getValue();
257259
if (value != null) {

0 commit comments

Comments
 (0)
X Tutup