Skip to content

Commit 34f327e

Browse files
author
Douglas Crockford
committed
out of the pool
1 parent 1f7056e commit 34f327e

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

JSONObject.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,9 @@ of this software and associated documentation files (the "Software"), to deal
9090
* </ul>
9191
*
9292
* @author JSON.org
93-
* @version 2013-04-18
93+
* @version 2013-06-17
9494
*/
9595
public class JSONObject {
96-
/**
97-
* The maximum number of keys in the key pool.
98-
*/
99-
private static final int keyPoolSize = 100;
100-
101-
/**
102-
* Key pooling is like string interning, but without permanently tying up
103-
* memory. To help conserve memory, storage of duplicated key strings in
104-
* JSONObjects will be avoided by using a key pool to manage unique key
105-
* string objects. This is used by JSONObject.put(string, object).
106-
*/
107-
private static HashMap keyPool = new HashMap(keyPoolSize);
108-
10996
/**
11097
* JSONObject.NULL is equivalent to the value that JavaScript calls null,
11198
* whilst Java's null is equivalent to the value that JavaScript calls
@@ -1147,21 +1134,11 @@ public JSONObject put(String key, Map value) throws JSONException {
11471134
* If the value is non-finite number or if the key is null.
11481135
*/
11491136
public JSONObject put(String key, Object value) throws JSONException {
1150-
String pooled;
11511137
if (key == null) {
11521138
throw new NullPointerException("Null key.");
11531139
}
11541140
if (value != null) {
11551141
testValidity(value);
1156-
pooled = (String) keyPool.get(key);
1157-
if (pooled == null) {
1158-
if (keyPool.size() >= keyPoolSize) {
1159-
keyPool = new HashMap(keyPoolSize);
1160-
}
1161-
keyPool.put(key, key);
1162-
} else {
1163-
key = pooled;
1164-
}
11651142
this.map.put(key, value);
11661143
} else {
11671144
this.remove(key);

0 commit comments

Comments
 (0)