mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 11:34:43 +08:00
change JSONObject(Map) constructor to use the default capacity when a null map is passed
This commit is contained in:
@@ -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) {
|
||||||
|
Reference in New Issue
Block a user