[pypy-commit] pypy default: Actually, we can just move that block of code outside the unrolled loop.

arigo pypy.commits at gmail.com
Wed Sep 21 08:07:38 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r87264:d9aeadc27510
Date: 2016-09-21 14:07 +0200
http://bitbucket.org/pypy/pypy/changeset/d9aeadc27510/

Log:	Actually, we can just move that block of code outside the unrolled
	loop.

diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -30,28 +30,25 @@
             raise oefmt(space.w_TypeError,
                         "array.array() does not take keyword arguments")
 
-    w_initializer_type = None
-    w_initializer = None
-    if len(__args__.arguments_w) > 0:
-        w_initializer = __args__.arguments_w[0]
-        w_initializer_type = space.type(w_initializer)
     for tc in unroll_typecodes:
         if typecode == tc:
             a = space.allocate_instance(types[tc].w_class, w_cls)
             a.__init__(space)
-            if w_initializer is not None:
-                if w_initializer_type is space.w_str:
-                    a.descr_fromstring(space, w_initializer)
-                elif w_initializer_type is space.w_list:
-                    a.descr_fromlist(space, w_initializer)
-                else:
-                    a.extend(w_initializer, True)
             break
     else:
         raise oefmt(space.w_ValueError,
                     "bad typecode (must be c, b, B, u, h, H, i, I, l, L, f or "
                     "d)")
 
+    if len(__args__.arguments_w) > 0:
+        w_initializer = __args__.arguments_w[0]
+        w_initializer_type = space.type(w_initializer)
+        if w_initializer_type is space.w_str:
+            a.descr_fromstring(space, w_initializer)
+        elif w_initializer_type is space.w_list:
+            a.descr_fromlist(space, w_initializer)
+        else:
+            a.extend(w_initializer, True)
     return a
 
 


More information about the pypy-commit mailing list