[svn:parrot] r48458 - branches/unshared_buffers/src/pmc

darbelo at svn.parrot.org darbelo at svn.parrot.org
Fri Aug 13 17:07:42 UTC 2010


Author: darbelo
Date: Fri Aug 13 17:07:42 2010
New Revision: 48458
URL: https://trac.parrot.org/parrot/changeset/48458

Log:
Update stringbuilder to the new substr semantics.

Modified:
   branches/unshared_buffers/src/pmc/stringbuilder.pmc

Modified: branches/unshared_buffers/src/pmc/stringbuilder.pmc
==============================================================================
--- branches/unshared_buffers/src/pmc/stringbuilder.pmc	Fri Aug 13 17:07:10 2010	(r48457)
+++ branches/unshared_buffers/src/pmc/stringbuilder.pmc	Fri Aug 13 17:07:42 2010	(r48458)
@@ -66,7 +66,7 @@
         buffer->encoding  = Parrot_default_encoding_ptr;
         buffer->charset   = Parrot_default_charset_ptr;
         /* We need all string flags here because we use this buffer in substr_str */
-        buffer->flags     = PObj_is_string_FLAG | PObj_live_FLAG | PObj_external_FLAG;
+        buffer->flags     = PObj_is_string_FLAG | PObj_live_FLAG;
         Buffer_bufstart(buffer) = mem_gc_allocate_n_typed(INTERP,
                 initial_size, char);
         Buffer_buflen(buffer) = initial_size;
@@ -145,7 +145,7 @@
             STRING * const new_buffer = Parrot_unicode_charset_ptr->to_charset(interp, buffer);
             mem_gc_free(INTERP, Buffer_bufstart(buffer));
             STRUCT_COPY(buffer, new_buffer);
-            buffer->flags     = PObj_is_string_FLAG | PObj_live_FLAG | PObj_external_FLAG;
+            buffer->flags     = PObj_is_string_FLAG | PObj_live_FLAG;
 
             Buffer_bufstart(buffer) = mem_gc_allocate_n_typed(INTERP,
                                                     Buffer_buflen(new_buffer), char);
@@ -275,10 +275,7 @@
     VTABLE STRING *substr_str(INTVAL offset, INTVAL length) {
         STRING *buffer;
         GET_ATTR_buffer(INTERP, SELF, buffer);
-        /* We must clone here becase we can reallocate buffer behind the scene... */
-        /* TODO Optimize it to avoid creation of redundant STRING */
-        return Parrot_str_clone(INTERP,
-                Parrot_str_substr(INTERP, buffer, offset, length));
+        return Parrot_str_substr(INTERP, buffer, offset, length);
     }
 
 /*


More information about the parrot-commits mailing list