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