[svn:parrot] r45866 - trunk/tools/dev

chromatic at svn.parrot.org chromatic at svn.parrot.org
Wed Apr 21 20:44:35 UTC 2010


Author: chromatic
Date: Wed Apr 21 20:44:35 2010
New Revision: 45866
URL: https://trac.parrot.org/parrot/changeset/45866

Log:
[tools] Fixed non-GCC, non-MSVC code generation in pbc_to_exe to avoid
expensive string concatenation (reported by Andy Dougherty, TT #1572).

Modified:
   trunk/tools/dev/pbc_to_exe.pir

Modified: trunk/tools/dev/pbc_to_exe.pir
==============================================================================
--- trunk/tools/dev/pbc_to_exe.pir	Wed Apr 21 20:44:31 2010	(r45865)
+++ trunk/tools/dev/pbc_to_exe.pir	Wed Apr 21 20:44:35 2010	(r45866)
@@ -217,9 +217,12 @@
     .local pmc ifh
     ifh = open infile, 'r'
     unless ifh goto err_infile
-    .local string codestring
+
+    .local pmc codestring
     .local int size
-    codestring = "const Parrot_UInt1 program_code[] = {"
+
+    codestring = new [ 'ResizableStringArray' ]
+    push codestring, "const Parrot_UInt1 program_code[] = {"
     size = 0
 
   read_loop:
@@ -236,13 +239,13 @@
     unless pos < pbclength goto code_done
     $I0 = ord pbcstring, pos
     $S0 = $I0
-    codestring .= $S0
-    codestring .= ','
+    push codestring, $S0
+    push codestring, ','
     inc pos
     inc size
     $I0 = size % 32
     unless $I0 == 0 goto code_loop
-    codestring .= "\n"
+    push codestring, "\n"
     goto code_loop
   code_done:
     goto read_loop
@@ -250,19 +253,19 @@
   read_done:
     close ifh
 
-    codestring .= "\n};\n\n"
-    codestring .= "const int bytecode_size = "
+    push codestring, "\n};\n\nconst int bytecode_size = "
     $S0 = size
-    codestring .= $S0
-    codestring .= ";\n"
-    codestring .= <<'END_OF_FUNCTION'
+    push codestring, $S0
+    push codestring, ";\n"
+    push codestring, <<'END_OF_FUNCTION'
         const void * get_program_code(void)
         {
             return program_code;
         }
 END_OF_FUNCTION
 
-    .return (codestring)
+    $S0 = join '', codestring
+    .return ($S0)
 
   err_infile:
     die "cannot open infile"


More information about the parrot-commits mailing list