summaryrefslogtreecommitdiff
path: root/simplejson/decoder.py
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2009-12-27 11:09:28 +0000
committerBob Ippolito <bob@redivi.com>2009-12-27 11:09:28 +0000
commitbc73ddee065b44769068e00b7f057aca650c5c23 (patch)
tree559d05476d44774d417cf6e00d6b3daf2dad4c7c /simplejson/decoder.py
parentbdc1425fcdc600562dc14818cad9627f01d9dd03 (diff)
downloadsimplejson-bc73ddee065b44769068e00b7f057aca650c5c23.tar.gz
http://bugs.python.org/issue7451
git-svn-id: http://simplejson.googlecode.com/svn/trunk@206 a4795897-2c25-0410-b006-0d3caba88fa1
Diffstat (limited to 'simplejson/decoder.py')
-rw-r--r--simplejson/decoder.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/simplejson/decoder.py b/simplejson/decoder.py
index 386db69..4bf4b18 100644
--- a/simplejson/decoder.py
+++ b/simplejson/decoder.py
@@ -175,7 +175,12 @@ WHITESPACE = re.compile(r'[ \t\n\r]*', FLAGS)
WHITESPACE_STR = ' \t\n\r'
def JSONObject((s, end), encoding, strict, scan_once, object_hook,
- object_pairs_hook, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
+ object_pairs_hook, memo=None,
+ _w=WHITESPACE.match, _ws=WHITESPACE_STR):
+ # Backwards compatibility
+ if memo is None:
+ memo = {}
+ memo_get = memo.setdefault
pairs = []
# Use a slice to prevent IndexError from being raised, the following
# check will raise a more specific ValueError if the string is empty
@@ -199,6 +204,7 @@ def JSONObject((s, end), encoding, strict, scan_once, object_hook,
end += 1
while True:
key, end = scanstring(s, end, encoding, strict)
+ key = memo_get(key, key)
# To skip some function call overhead we optimize the fast paths where
# the JSON key separator is ": " or just ":".
@@ -382,6 +388,7 @@ class JSONDecoder(object):
self.parse_object = JSONObject
self.parse_array = JSONArray
self.parse_string = scanstring
+ self.memo = {}
self.scan_once = make_scanner(self)
def decode(self, s, _w=WHITESPACE.match):