Author: Armin Rigo <[email protected]>
Branch: stringbuilder2-perf
Changeset: r72054:31ad9da78807
Date: 2014-06-15 12:24 +0200
http://bitbucket.org/pypy/pypy/changeset/31ad9da78807/

Log:    unicode fixes

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
@@ -60,7 +60,8 @@
         #
         new_string = mallocfn(needed)
         #
-        old_piece = lltype.malloc(STRINGPIECE)
+        PIECE = lltype.typeOf(ll_builder.extra_pieces).TO
+        old_piece = lltype.malloc(PIECE)
         old_piece.buf = ll_builder.current_buf
         old_piece.prev_piece = ll_builder.extra_pieces
         ll_builder.extra_pieces = old_piece
@@ -106,16 +107,22 @@
     }
 )
 
+UNICODEPIECE = lltype.GcStruct('unicodepiece',
+    ('buf', lltype.Ptr(UNICODE)),
+    ('prev_piece', lltype.Ptr(lltype.GcForwardReference())))
+UNICODEPIECE.prev_piece.TO.become(UNICODEPIECE)
+
 UNICODEBUILDER = lltype.GcStruct('unicodebuilder',
     ('current_buf', lltype.Ptr(UNICODE)),
-    ('current_ofs', lltype.Signed),     # position measured in *bytes*
-    ('current_end', lltype.Signed),     # position measured in *bytes*
+    ('current_pos', lltype.Signed),
+    ('current_end', lltype.Signed),
     ('total_size', lltype.Signed),
-    ('extra_pieces', lltype.Ptr(STRINGPIECE)),
-    ('initial_buf', lltype.Ptr(UNICODE)),
+    ('skip', lltype.Signed),
+    ('extra_pieces', lltype.Ptr(UNICODEPIECE)),
     adtmeths={
         'grow': staticAdtMethod(unicodebuilder_grows[0]),
         'append_overflow': staticAdtMethod(unicodebuilder_grows[1]),
+        'copy_string_contents': staticAdtMethod(rstr.copy_unicode_contents),
         'copy_raw_to_string': staticAdtMethod(rstr.copy_raw_to_unicode),
     }
 )
@@ -338,7 +345,7 @@
         final_size = cls.ll_getlength(ll_builder)
         ll_assert(final_size >= 0, "negative final_size")
         extra = ll_builder.extra_pieces
-        ll_builder.extra_pieces = lltype.nullptr(STRINGPIECE)
+        ll_builder.extra_pieces = lltype.nullptr(lltype.typeOf(extra).TO)
         #
         result = cls.mallocfn(final_size)
         piece = ll_builder.current_buf
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to