[pypy-commit] pypy faster-json: a little speedup

fijal noreply at buildbot.pypy.org
Thu Oct 20 13:38:40 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: faster-json
Changeset: r48263:947621c9169c
Date: 2011-10-20 13:38 +0200
http://bitbucket.org/pypy/pypy/changeset/947621c9169c/

Log:	a little speedup

diff --git a/lib-python/modified-2.7/json/encoder.py b/lib-python/modified-2.7/json/encoder.py
--- a/lib-python/modified-2.7/json/encoder.py
+++ b/lib-python/modified-2.7/json/encoder.py
@@ -55,7 +55,9 @@
                 s2 = 0xdc00 | (n & 0x3ff)
                 #return '\\u{0:04x}\\u{1:04x}'.format(s1, s2)
                 return '\\u%04x\\u%04x' % (s1, s2)
-    return str(ESCAPE_ASCII.sub(replace, s))
+    if ESCAPE_ASCII.search(s):
+        return str(ESCAPE_ASCII.sub(replace, s))
+    return s
 py_encode_basestring_ascii = lambda s: '"' + encode_basestring_ascii(s) + '"'
 c_encode_basestring_ascii = None
 


More information about the pypy-commit mailing list