Author: Armin Rigo <[email protected]>
Branch: cpyext-ext
Changeset: r84900:158c9efd5ffd
Date: 2016-06-03 14:59 +0200
http://bitbucket.org/pypy/pypy/changeset/158c9efd5ffd/

Log:    Expose to the JIT the type dispatching part of _do_setslice(), at
        least

diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -245,10 +245,17 @@
                     raise oefmt(space.w_ValueError,
                                 "need a bytearray of length %d, got %d",
                                 length, len(value))
-                for i in range(length):
-                    target[i] = value[i]
+                self._copy_list_of_chars_to_raw(value, target, length)
                 return
         #
+        self._do_setslice_iterate(space, ctitem, w_value, target, ctitemsize,
+                                  length)
+
+    @staticmethod
+    def _do_setslice_iterate(space, ctitem, w_value, target, ctitemsize,
+                             length):
+        # general case, contains a loop
+        # (XXX is it worth adding a jitdriver here?)
         w_iter = space.iter(w_value)
         for i in range(length):
             try:
@@ -269,6 +276,12 @@
             raise oefmt(space.w_ValueError,
                         "got more than %d values to unpack", length)
 
+    @staticmethod
+    def _copy_list_of_chars_to_raw(value, target, length):
+        # contains a loop, moved out of _do_setslice()
+        for i in range(length):
+            target[i] = value[i]
+
     def _add_or_sub(self, w_other, sign):
         space = self.space
         i = sign * space.getindex_w(w_other, space.w_OverflowError)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to