Daniel Sheppard wrote: >> Given that I only want to compute the offsets once, an >> obvious solution >> would be to construct an Array of String - each element >> representing a >> sub-string of the original... but this would double memory use. What >> would be the best way to avoid duplicating the character >> sequences and >> causing run-time bloat? > > I might be wrong You're not. > - but I'm pretty sure that substrings in ruby are > created with copy-on-write. That is, when you take a substring, a new > block of memory isn't allocated to the new String, it references the > same block of memory as the original string - the allocation of a new > block of memory only occurs when one of the strings is modified. Exactly. It seems this would be the simplest solution. robert