Author: Antonio Cuni <anto.c...@gmail.com>
Branch: faster-rstruct-2
Changeset: r91276:f99d6f69a91c
Date: 2017-05-13 00:31 +0200
http://bitbucket.org/pypy/pypy/changeset/f99d6f69a91c/

Log:    unroll the loop if count is a small constant

diff --git a/rpython/rlib/mutbuffer.py b/rpython/rlib/mutbuffer.py
--- a/rpython/rlib/mutbuffer.py
+++ b/rpython/rlib/mutbuffer.py
@@ -4,6 +4,7 @@
 from rpython.rtyper.annlowlevel import llstr, hlstr
 from rpython.rlib.objectmodel import specialize
 from rpython.rlib.buffer import Buffer
+from rpython.rlib import jit
 
 class MutableStringBuffer(Buffer):
     """
@@ -46,6 +47,8 @@
     def setitem(self, index, char):
         self.ll_val.chars[index] = char
 
+    @jit.look_inside_iff(lambda self, index, count:
+                         jit.isconstant(count) and count <= 8)
     def setzeros(self, index, count):
         for i in range(index, index+count):
             self.setitem(i, '\x00')
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to