Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r59452:5d9059caa546
Date: 2012-12-15 13:46 +0200
http://bitbucket.org/pypy/pypy/changeset/5d9059caa546/
Log: preallocate stuff in charp2str
diff --git a/pypy/rpython/lltypesystem/rffi.py
b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -710,7 +710,10 @@
# char* -> str
# doesn't free char*
def charp2str(cp):
- b = builder_class()
+ size = 0
+ while cp[size] != lastchar:
+ size += 1
+ b = builder_class(size)
i = 0
while cp[i] != lastchar:
b.append(cp[i])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit