[pypy-svn] r54397 - pypy/branch/io-improvements/pypy/rpython/lltypesystem
fijal at codespeak.net
fijal at codespeak.net
Sun May 4 13:49:41 CEST 2008
Author: fijal
Date: Sun May 4 13:49:39 2008
New Revision: 54397
Modified:
pypy/branch/io-improvements/pypy/rpython/lltypesystem/rstr.py
Log:
Last occurence of copying characters by hand in rstr. it seems that using
raw_memcopy gives some small speedups here and there, but at least we've got
string copying in a single place
Modified: pypy/branch/io-improvements/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rpython/lltypesystem/rstr.py (original)
+++ pypy/branch/io-improvements/pypy/rpython/lltypesystem/rstr.py Sun May 4 13:49:39 2008
@@ -238,6 +238,7 @@
times = 0
newstr = malloc(times)
j = 0
+ # XXX we can use memset here, not sure how useful this is
while j < times:
newstr.chars[j] = ch
j += 1
@@ -594,8 +595,10 @@
i += 1
if typeOf(items).TO.OF.TO == STR:
malloc = mallocstr
+ copy_contents = copy_string_contents
else:
malloc = mallocunicode
+ copy_contents = copy_unicode_contents
result = malloc(itemslen)
res_chars = result.chars
res_index = 0
@@ -603,15 +606,14 @@
while i < num_items:
item_chars = items[i].chars
item_len = len(item_chars)
- j = 0
- while j < item_len:
- res_chars[res_index] = item_chars[j]
- j += 1
- res_index += 1
+ copy_contents(result, items[i], res_index, 0, item_len)
+ res_index += item_len
i += 1
return result
def ll_join_chars(length, chars):
+ # no need to optimize this, will be replaced by string builder
+ # at some point soon
num_chars = length
if typeOf(chars).TO.OF == Char:
malloc = mallocstr
More information about the Pypy-commit
mailing list