[pypy-commit] pypy length-hint: an ootype _ll_resize_hint attempt

pjenvey noreply at buildbot.pypy.org
Sat Jul 14 23:41:24 CEST 2012


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: length-hint
Changeset: r56080:4aaf1a409fbf
Date: 2012-07-14 14:38 -0700
http://bitbucket.org/pypy/pypy/changeset/4aaf1a409fbf/

Log:	an ootype _ll_resize_hint attempt

diff --git a/pypy/rpython/ootypesystem/ootype.py b/pypy/rpython/ootypesystem/ootype.py
--- a/pypy/rpython/ootypesystem/ootype.py
+++ b/pypy/rpython/ootypesystem/ootype.py
@@ -580,6 +580,7 @@
             "_ll_resize_ge": Meth([Signed], Void),
             "_ll_resize_le": Meth([Signed], Void),
             "_ll_resize": Meth([Signed], Void),
+            "_ll_resize_hint": Meth([Signed], Void),
         })
 
         self._setup_methods(generic_types)
diff --git a/pypy/rpython/rlist.py b/pypy/rpython/rlist.py
--- a/pypy/rpython/rlist.py
+++ b/pypy/rpython/rlist.py
@@ -26,6 +26,8 @@
     '_ll_resize_le':   (['self', Signed        ], Void),
     # resize to exactly the given size
     '_ll_resize':      (['self', Signed        ], Void),
+    # realloc the underlying list
+    '_ll_resize_hint': (['self', Signed        ], Void),
 })
 
 
diff --git a/pypy/translator/cli/src/pypylib.cs b/pypy/translator/cli/src/pypylib.cs
--- a/pypy/translator/cli/src/pypylib.cs
+++ b/pypy/translator/cli/src/pypylib.cs
@@ -840,6 +840,11 @@
                 this._ll_resize_le(length);
         }
 
+        public void _ll_resize_hint(int length)
+        {
+            this.Capacity(length);
+        }
+
         public void _ll_resize_ge(int length)
         {
             if (this.Count < length) 
diff --git a/pypy/translator/jvm/src/pypy/PyPy.java b/pypy/translator/jvm/src/pypy/PyPy.java
--- a/pypy/translator/jvm/src/pypy/PyPy.java
+++ b/pypy/translator/jvm/src/pypy/PyPy.java
@@ -1085,6 +1085,10 @@
             _ll_resize_le(self, length); 
     }
 
+    public static void _ll_resize_hint(ArrayList self, int length) {
+        self.ensureCapacity(length);
+    }
+
     // ----------------------------------------------------------------------
     // ll_math
     //


More information about the pypy-commit mailing list