Skip to content

Commit

Permalink
Switched to using reversed. THIS REQUIRES UPGRADING YOUR PYPY CHECKOUT.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Gaynor committed Apr 29, 2013
1 parent 70b72b4 commit 48a0ca3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions topaz/ast.py
Expand Up @@ -822,8 +822,7 @@ def compile(self, ctx):
for name, pos in block_ctx.symtable.cell_numbers.iteritems():
cells[pos] = name
num_cells = 0
for i in xrange(len(cells) - 1, -1, -1):
name = cells[i]
for name in reversed(cells):
if block_ctx.symtable.cells[name] == block_ctx.symtable.FREEVAR:
ctx.emit(consts.LOAD_CLOSURE, ctx.symtable.get_cell_num(name))
num_cells += 1
Expand Down
6 changes: 3 additions & 3 deletions topaz/astcompiler.py
Expand Up @@ -212,9 +212,9 @@ def in_frame_block(self, block_type):
return False

def find_frame_block(self, block_type):
for i in xrange(len(self.frame_blocks) - 1, -1, -1):
if self.frame_blocks[i][0] == block_type:
return self.frame_blocks[i][1]
for frame_block in reversed(self.frame_blocks):
if frame_block[0] == block_type:
return frame_block[1]
raise SystemError

def new_block(self):
Expand Down
3 changes: 1 addition & 2 deletions topaz/objects/arrayobject.py
Expand Up @@ -209,8 +209,7 @@ def method_shift(self, space, w_n=None):
@classdef.method("unshift")
@check_frozen()
def method_unshift(self, space, args_w):
for i in xrange(len(args_w) - 1, -1, -1):
w_obj = args_w[i]
for w_obj in reversed(args_w):
self.items_w.insert(0, w_obj)
return self

Expand Down
9 changes: 3 additions & 6 deletions topaz/objects/moduleobject.py
Expand Up @@ -184,9 +184,7 @@ def _find_const_pure(self, name, version):

@jit.unroll_safe
def set_class_var(self, space, name, w_obj):
ancestors = self.ancestors()
for idx in xrange(len(ancestors) - 1, -1, -1):
module = ancestors[idx]
for module in reversed(self.ancestors()):
assert isinstance(module, W_ModuleObject)
w_res = module.class_variables.get(space, name)
if w_res is not None or module is self:
Expand Down Expand Up @@ -326,9 +324,8 @@ def method_include(self, space, w_mod):

@classdef.method("append_features")
def method_append_features(self, space, w_mod):
ancestors = self.ancestors()
for idx in xrange(len(ancestors) - 1, -1, -1):
w_mod.include_module(space, ancestors[idx])
for module in reversed(self.ancestors()):
w_mod.include_module(space, module)

@classdef.method("define_method", name="symbol")
def method_define_method(self, space, name, w_method=None, block=None):
Expand Down

0 comments on commit 48a0ca3

Please sign in to comment.