Author: Antonio Cuni <[email protected]>
Branch: fastjson
Changeset: r64843:2a7d18573294
Date: 2013-06-07 18:43 +0200
http://bitbucket.org/pypy/pypy/changeset/2a7d18573294/

Log:    remove the last end-of-string check

diff --git a/pypy/module/_fastjson/interp_decoder.py 
b/pypy/module/_fastjson/interp_decoder.py
--- a/pypy/module/_fastjson/interp_decoder.py
+++ b/pypy/module/_fastjson/interp_decoder.py
@@ -49,7 +49,6 @@
         # we put a sentinel at the end so that we never have to check for the
         # "end of string" condition
         self.ll_chars = llstr(s+'\0').chars
-        self.length = len(s)
         self.pos = 0
         self.last_type = TYPE_UNKNOWN
 
@@ -241,7 +240,7 @@
     def decode_string(self, i):
         start = i
         bits = 0
-        while i < self.length:
+        while True:
             # this loop is a fast path for strings which do not contain escape
             # characters
             ch = self.ll_chars[i]
@@ -264,7 +263,8 @@
                 content_so_far = self.getslice(start, i-1)
                 self.pos = i-1
                 return self.decode_string_escaped(start, content_so_far)
-        self._raise("Unterminated string starting at char %d", start)
+            elif ch == '\0':
+                self._raise("Unterminated string starting at char %d", start)
 
 
     def decode_string_escaped(self, start, content_so_far):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to