Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: record-known-result
Changeset: r97808:7cf364a94ebb
Date: 2019-10-18 10:00 +0200
http://bitbucket.org/pypy/pypy/changeset/7cf364a94ebb/

Log:    fix hint for corner cases, add rfind version

diff --git a/rpython/rtyper/lltypesystem/rstr.py 
b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -728,14 +728,15 @@
             return -1
 
         m = len(s2.chars)
-        if m == 1:
+        if m <= 1:
+            if m == 0:
+                return start
             res = LLHelpers.ll_find_char(s1, s2.chars[0], start, end)
             jit.record_exact_value(res < end, True)
             return res
 
         res = LLHelpers.ll_search(s1, s2, start, end, FAST_FIND)
         jit.record_exact_value(res < end, True)
-        jit.record_exact_value(res + m <= n, True)
         return res
 
     @staticmethod
@@ -749,10 +750,17 @@
             return -1
 
         m = len(s2.chars)
-        if m == 1:
-            return LLHelpers.ll_rfind_char(s1, s2.chars[0], start, end)
+        if m <= 1:
+            if m == 0:
+                return end
+            LLHelpers.ll_find_char(s1, s2.chars[0], start, end)
+            res = LLHelpers.ll_rfind_char(s1, s2.chars[0], start, end)
+            jit.record_exact_value(res < end, True)
+            return res
 
-        return LLHelpers.ll_search(s1, s2, start, end, FAST_RFIND)
+        res = LLHelpers.ll_search(s1, s2, start, end, FAST_RFIND)
+        jit.record_exact_value(res < end, True)
+        return res
 
     @classmethod
     def ll_count(cls, s1, s2, start, end):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to