Author: fijal
Branch: unicode-utf8
Changeset: r92639:fcee89117042
Date: 2017-10-07 18:33 +0200
http://bitbucket.org/pypy/pypy/changeset/fcee89117042/

Log:    fastpath for find() without any args, also mention in TODO

diff --git a/TODO b/TODO
--- a/TODO
+++ b/TODO
@@ -1,3 +1,5 @@
 * unskip tests in test_unicodeobject.py
 * rutf8.prev_codepoint_pos should use r_uint
-* elidable in rutf8.check_utf8, WTF is wrong with that
\ No newline at end of file
+* elidable in rutf8.check_utf8, WTF is wrong with that
+* find a better way to run "find" without creating the index storage,
+  if one is not already readily available
\ No newline at end of file
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -418,10 +418,16 @@
 
         w_sub = self.convert_arg_to_w_unicode(space, w_sub)
         # XXX for now just create index
-        storage = self._get_index_storage()
-        start_index = rutf8.codepoint_position_at_index(self._utf8, storage,
-                                                        start)
-        end_index = rutf8.codepoint_position_at_index(self._utf8, storage, end)
+        start_index = 0
+        end_index = len(self._utf8)
+        if start > 0 or end != self._length:
+            storage = self._get_index_storage()
+            if start > 0:
+                start_index = rutf8.codepoint_position_at_index(self._utf8,
+                    storage, start)
+            if end != self.length:
+                end_index = rutf8.codepoint_position_at_index(self._utf8,
+                    storage, end)
 
         res_index = value.find(w_sub._utf8, start_index, end_index)
         if res_index == -1:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to