Author: Antonio Cuni <[email protected]>
Branch: improve-str2charp
Changeset: r65266:fe711f557c8f
Date: 2013-07-08 16:01 +0200
http://bitbucket.org/pypy/pypy/changeset/fe711f557c8f/
Log: use copy_string_to_raw to implement also get_nonmovingbuffer: this
should improve our I/O writing speed
diff --git a/rpython/rtyper/lltypesystem/rffi.py
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -740,14 +740,14 @@
string is already nonmovable. Must be followed by a
free_nonmovingbuffer call.
"""
+ lldata = llstrtype(data)
if rgc.can_move(data):
count = len(data)
buf = lltype.malloc(TYPEP.TO, count, flavor='raw')
- for i in range(count):
- buf[i] = data[i]
+ copy_string_to_raw(lldata, buf, 0, count)
return buf
else:
- data_start = cast_ptr_to_adr(llstrtype(data)) + \
+ data_start = cast_ptr_to_adr(lldata) + \
offsetof(STRTYPE, 'chars') + itemoffsetof(STRTYPE.chars, 0)
return cast(TYPEP, data_start)
get_nonmovingbuffer._annenforceargs_ = [strtype]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit