At 06:16 PM 7/2/2001 -0400, Uri Guttman wrote:
> >>>>> "DS" == Dan Sugalski <[EMAIL PROTECTED]> writes:
>
> DS> At 09:07 PM 7/2/2001 +0100, Graham Barr wrote:
> >> I for one use s/^...// quite often in the knowledge that it is
> optimized to
> >> just move a pointer and not cause a copy of the string.
>
> DS> We'll still be doing that. (The leftover memory will get cleaned
> DS> up when we GC) The bigger issue is when we need to move the
> DS> pointer back because we've stuck something back on the front of
> DS> the string.
>
>do you mean the buffer pointer itself gets bumped when you chop off the
>beginning?
Yes. And the buffer size shrinks accordingly.
>how would that allow GC since the collector wouldn't know
>about the offset pointer?
We're going to use a copying collector. When the string gets copied as part
of a compaction run things'll get cleaned up appropriately. (Not that
there's really any cleanup to do in that case) Granted the destination
string buffer will only be as big as the source buffer 'really' is (which
is to say the amount of memory actually in the string plus the extra bit at
the end, if there is any) but that's fine.
>maybe there is a GC trick to do that. having
>the offset means you don't lose the main buffer pointer so GC will be
>simpler.
Nah, with a copying collector it's actually a little easier. The fewer
fields that need checking the faster things are.
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk