# New Ticket Created by "Peter Gibbs" # Please include the string: [netlabs #607] # in the subject line of all future correspondence about this issue. # <URL: http://bugs6.perl.org/rt2/Ticket/Display.html?id=607 >
Attached is another patch to implement copy-on-write strings. Summary of changes * New field 'buffer' in STRING points to the start of the allocated buffer. I have put this field immediately after the Buffer fields, in case we want to create a generic subclass of Buffer with the same functionality * The existing 'bufstart' field is redefined as pointing to the start of the string data, this is what all code outside the memory manager expects anyway * Similarly, buflen means the distance from bufstart to the end of the buffer, rather than the physical size of the buffer * New struct String_Tail, added at the end of each string buffer, for private use by the garbage collector * Parrot_(re)allocate_string changed to add the tail for non-constant strings * Parrot_reallocate_string now takes an additional parameter to specify the flags required for the new buffer * compact_string_pool handles COW strings appropriately; the logic caters for both full strings and substrings, and clears the COW flag on buffers that become unshared * string_copy and string_substr changed to create COWs, note that the 'const' attribute has been removed from these, as well as string_transcode, since the COW process sets a flag in the source string * string_replace changed significantly, to use COW features where possible These changes should have no impact on any code outside of string.c and resources.c Performance should be improved for string-intensive processing in most cases; for example, my tests show approximately a 5% improvement in life.pasm. The next patch will be some documentation for the memory management system, if I can figure out how it works. -- Peter Gibbs EmKel Systems