Commits

Armin Rigo  committed d994777

Jit: avoid a guard "len(s2) != 0" in the common case, just to handle
the unusual case of find(s, '') or count(s, '').

  • Participants
  • Parent commits d2d8b7c

Comments (0)

Files changed (1)

File rpython/rtyper/lltypesystem/rstr.py

             return -1
 
         m = len(s2.chars)
-        if m == 0:
-            return start
-        elif m == 1:
+        if m == 1:
             return cls.ll_find_char(s1, s2.chars[0], start, end)
 
         return cls.ll_search(s1, s2, start, end, FAST_FIND)
             return -1
 
         m = len(s2.chars)
-        if m == 0:
-            return end
-        elif m == 1:
+        if m == 1:
             return cls.ll_rfind_char(s1, s2.chars[0], start, end)
 
         return cls.ll_search(s1, s2, start, end, FAST_RFIND)
             return 0
 
         m = len(s2.chars)
-        if m == 0:
-            return end - start + 1
-        elif m == 1:
+        if m == 1:
             return cls.ll_count_char(s1, s2.chars[0], start, end)
 
         res = cls.ll_search(s1, s2, start, end, FAST_COUNT)
         n = end - start
         m = len(s2.chars)
 
+        if m == 0:
+            if mode == FAST_COUNT:
+                return end - start + 1
+            elif mode == FAST_RFIND:
+                return end
+            else:
+                return start
+
         w = n - m
 
         if w < 0: