[pypy-svn] r50422 - pypy/dist/pypy/objspace/std

arigo at codespeak.net arigo at codespeak.net
Mon Jan 7 14:21:22 CET 2008


Author: arigo
Date: Mon Jan  7 14:21:21 2008
New Revision: 50422

Modified:
   pypy/dist/pypy/objspace/std/objspace.py
Log:
Fix an XXX before I forget about it.


Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py	(original)
+++ pypy/dist/pypy/objspace/std/objspace.py	Mon Jan  7 14:21:21 2008
@@ -622,12 +622,17 @@
             self.setitem(w_obj, w_key, w_value)
 
     def getindex_w(self, w_obj, w_exception, objdescr=None):
-        # performance shortcut for W_IntObject
-        # XXX we should also have one for W_SmallIntObject, I guess
-        if type(w_obj) is W_IntObject:
-            return w_obj.intval
+        # Performance shortcut for the common case of w_obj being an int.
+        # If withsmallint is disabled, we check for W_IntObject.
+        # If withsmallint is enabled, we only check for W_SmallIntObject - it's
+        # probably not useful to have a shortcut for W_IntObject at all then.
+        if self.config.objspace.std.withsmallint:
+            if type(w_obj) is W_SmallIntObject:
+                return w_obj.intval
         else:
-            return ObjSpace.getindex_w(self, w_obj, w_exception, objdescr)
+            if type(w_obj) is W_IntObject:
+                return w_obj.intval
+        return ObjSpace.getindex_w(self, w_obj, w_exception, objdescr)
 
     def call_method(self, w_obj, methname, *arg_w):
         if self.config.objspace.opcodes.CALL_METHOD:



More information about the Pypy-commit mailing list