[pypy-svn] r48087 - pypy/dist/pypy/lang/smalltalk
arigo at codespeak.net
arigo at codespeak.net
Fri Oct 26 18:52:20 CEST 2007
Author: arigo
Date: Fri Oct 26 18:52:20 2007
New Revision: 48087
Modified:
pypy/dist/pypy/lang/smalltalk/model.py
pypy/dist/pypy/lang/smalltalk/primitives.py
Log:
pop_n() is called very often and was causing unnecessary allocations.
Fixing it gives a 2x speed-up in the translated version! :-)
Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py (original)
+++ pypy/dist/pypy/lang/smalltalk/model.py Fri Oct 26 18:52:20 2007
@@ -377,8 +377,14 @@
assert n >= 0
start = len(self.stack) - n
assert start >= 0 # XXX what if this fails?
+ del self.stack[start:]
+
+ def pop_and_return_n(self, n):
+ assert n >= 0
+ start = len(self.stack) - n
+ assert start >= 0 # XXX what if this fails?
res = self.stack[start:]
- self.stack = self.stack[:start]
+ del self.stack[start:]
return res
class W_BlockContext(W_ContextPart):
Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py (original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py Fri Oct 26 18:52:20 2007
@@ -668,7 +668,7 @@
# Initialize the block stack with the arguments that were
# pushed. Also pop the receiver.
- block_args = frame.pop_n(exp_arg_cnt)
+ block_args = frame.pop_and_return_n(exp_arg_cnt)
w_block_ctx.push_all(block_args)
frame.pop()
More information about the Pypy-commit
mailing list