From 34f327e6d070568256b314479be158589d391891 Mon Sep 17 00:00:00 2001 From: Douglas Crockford Date: Mon, 17 Jun 2013 17:10:27 -0700 Subject: [PATCH] out of the pool --- JSONObject.java | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/JSONObject.java b/JSONObject.java index 9d2d5ce..5ca5a45 100755 --- a/JSONObject.java +++ b/JSONObject.java @@ -90,22 +90,9 @@ import java.util.Set; * * * @author JSON.org - * @version 2013-04-18 + * @version 2013-06-17 */ public class JSONObject { - /** - * The maximum number of keys in the key pool. - */ - private static final int keyPoolSize = 100; - - /** - * Key pooling is like string interning, but without permanently tying up - * memory. To help conserve memory, storage of duplicated key strings in - * JSONObjects will be avoided by using a key pool to manage unique key - * string objects. This is used by JSONObject.put(string, object). - */ - private static HashMap keyPool = new HashMap(keyPoolSize); - /** * JSONObject.NULL is equivalent to the value that JavaScript calls null, * whilst Java's null is equivalent to the value that JavaScript calls @@ -1147,21 +1134,11 @@ public class JSONObject { * If the value is non-finite number or if the key is null. */ public JSONObject put(String key, Object value) throws JSONException { - String pooled; if (key == null) { throw new NullPointerException("Null key."); } if (value != null) { testValidity(value); - pooled = (String) keyPool.get(key); - if (pooled == null) { - if (keyPool.size() >= keyPoolSize) { - keyPool = new HashMap(keyPoolSize); - } - keyPool.put(key, key); - } else { - key = pooled; - } this.map.put(key, value); } else { this.remove(key);