[pypy-commit] pypy stringbuilder2-perf: append_charpsize()
arigo
noreply at buildbot.pypy.org
Sun Jun 15 12:37:14 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stringbuilder2-perf
Changeset: r72053:85c98f36d29b
Date: 2014-06-15 12:22 +0200
http://bitbucket.org/pypy/pypy/changeset/85c98f36d29b/
Log: append_charpsize()
diff --git a/rpython/rtyper/lltypesystem/rbuilder.py b/rpython/rtyper/lltypesystem/rbuilder.py
--- a/rpython/rtyper/lltypesystem/rbuilder.py
+++ b/rpython/rtyper/lltypesystem/rbuilder.py
@@ -295,23 +295,18 @@
@staticmethod
@jit.dont_look_inside
def ll_append_charpsize(ll_builder, charp, size):
- lgt = size * ll_builder.charsize # in bytes
- ofs = ll_builder.current_ofs
- newofs = ofs + lgt
- if uint_gt(newofs, ll_builder.current_end):
- if ll_builder.charsize == 1:
- ll_str = llstr(rffi.charpsize2str(charp, size))
- else:
- ll_str = llunicode(rffi.wcharpsize2unicode(charp, size))
- ll_builder.append_overflow(ll_builder, ll_str)
- else:
- ll_builder.current_ofs = newofs
- # --- no GC! ---
- raw = rffi.cast(rffi.CCHARP, ll_builder.current_buf)
- rffi.c_memcpy(rffi.ptradd(raw, ofs),
- rffi.cast(rffi.CCHARP, charp),
- lgt)
- # --- end ---
+ part1 = ll_builder.current_end - ll_builder.current_pos
+ if size > part1:
+ # First, the part that still fits
+ ll_builder.copy_raw_to_string(charp, ll_builder.current_buf,
+ ll_builder.current_pos, part1)
+ charp = rffi.ptradd(charp, part1)
+ size -= part1
+ ll_builder.grow(ll_builder, size)
+ #
+ pos = ll_builder.current_pos
+ ll_builder.current_pos = pos + size
+ ll_builder.copy_raw_to_string(charp, ll_builder.current_buf, pos, size)
@staticmethod
@always_inline
More information about the pypy-commit
mailing list