[pypy-commit] pypy default: Speed up zlib a bit by using memcpy in place a loop
alex_gaynor
noreply at buildbot.pypy.org
Wed Apr 23 19:35:12 CEST 2014
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r70888:c65c33511bc7
Date: 2014-04-23 10:34 -0700
http://bitbucket.org/pypy/pypy/changeset/c65c33511bc7/
Log: Speed up zlib a bit by using memcpy in place a loop
diff --git a/rpython/rlib/rzlib.py b/rpython/rlib/rzlib.py
--- a/rpython/rlib/rzlib.py
+++ b/rpython/rlib/rzlib.py
@@ -3,7 +3,9 @@
from rpython.rlib import rgc
from rpython.rlib.rstring import StringBuilder
+from rpython.rtyper.annlowlevel import llstr
from rpython.rtyper.lltypesystem import rffi, lltype
+from rpython.rtyper.lltypesystem.rstr import copy_string_to_raw
from rpython.rtyper.tool import rffi_platform
from rpython.translator.platform import platform as compiler, CompilationError
from rpython.translator.tool.cbuild import ExternalCompilationInfo
@@ -347,8 +349,7 @@
"""
# Prepare the input buffer for the stream
with lltype.scoped_alloc(rffi.CCHARP.TO, len(data)) as inbuf:
- for i in xrange(len(data)):
- inbuf[i] = data[i]
+ copy_string_to_raw(llstr(data), inbuf, 0, len(data))
stream.c_next_in = rffi.cast(Bytefp, inbuf)
rffi.setintfield(stream, 'c_avail_in', len(data))
More information about the pypy-commit
mailing list