[pypy-commit] pypy list-strategies: Refactored RangeListStrateg.pop()

l.diekmann noreply at buildbot.pypy.org
Fri Sep 23 13:12:15 CEST 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47458:6f8c358e4389
Date: 2011-03-09 14:12 +0100
http://bitbucket.org/pypy/pypy/changeset/6f8c358e4389/

Log:	Refactored RangeListStrateg.pop()

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -357,16 +357,12 @@
 
         #XXX merge these parts
         l = self.cast_from_void_star(w_list.storage)
-        if index == 0:
+        if index in [0, self.length(w_list)-1]:
             r = self.getitem(w_list, index)
-            new = self.cast_to_void_star((l[0]+l[1],l[1],l[2]-1))
-            w_list.storage = new
-            w_list.check_empty_strategy()
-            return r
-
-        if index == self.length(w_list)-1:
-            r = self.getitem(w_list, index)
-            new = self.cast_to_void_star((l[0],l[1],l[2]-1))
+            if index == 0:
+                new = self.cast_to_void_star((l[0]+l[1],l[1],l[2]-1))
+            else:
+                new = self.cast_to_void_star((l[0],l[1],l[2]-1))
             w_list.storage = new
             w_list.check_empty_strategy()
             return r


More information about the pypy-commit mailing list