[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Global change to strings...
- To: info-macl@cambridge.apple.COM
- Subject: Re: Global change to strings...
- From: Kevin Gallagher <Gallagher@gilgamesh.cs.umass.edu>
- Date: Mon, 24 Jun 91 14:08:37 EDT
- Cc: CXEA@MCGILLA.BITNET
- Reply-to: Gallagher@cs.umass.edu
- Sender: Gallagher@Gilgamesh
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