[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global change to strings...



To avoid creating new strings unnecessarily, I would suggest using
strings with fill pointers.  e.g.,

    (make-array 128 :element-type 'string-char :fill-pointer 0)

You will need a function to copy characters into this `mutable string'
(copy the characters in, set the fill pointer).

Your string substitute function can then move the characters around
depending on the lengths of the source and replacement strings.  It will
also adjust the fill pointer to reflect the length of the new string.

As an added benefit, doing it this way will preserve EQness.  It's a bit
of extra work, but if you are doing a lot of string manipulation it's
worth it to avoid generating all that garbage.

Kevin Gallagher