in reply to Re: Is there something faster than string concatenation?
in thread Is there something faster than string concatenation?
Ok, that much makes sense. But I'd think I'd be running into a contiguous memory block problem. I mean, if this were C, I could realloc the buffer that has the first string in it, and if I'm lucky it wouldn't have to move, then I can just copy in the second string.
Over the course of doing this, every once in a while your realloc is going to need to move/copy. It seems like that should bite you over the long run.
But perhaps the open scalar ref basically just fronts for string concatenation? The usual approach for like a memory-based buffer from other languages is to grow the buffer larger than I need it for this one copy, so future copies won't have to risk the buffer moving.
Maybe my test is a little too perfect. Nothing else is competing for memory, so the string easily grows without bumping into anything? Of course, the only time this matters is in a tight loop iterating over a large dataset, where I shouldn't really be doing any extraneous allocations or anything anyway.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Is there something faster than string concatenation?
by Joost (Canon) on Dec 03, 2007 at 02:49 UTC | |
Re^3: Is there something faster than string concatenation? (hermit crabs)
by tye (Sage) on Dec 03, 2007 at 07:07 UTC | |
by ikegami (Patriarch) on Dec 03, 2007 at 07:37 UTC | |
by eyepopslikeamosquito (Archbishop) on Dec 03, 2007 at 11:23 UTC | |
by tye (Sage) on Dec 03, 2007 at 19:21 UTC | |
by Joost (Canon) on Dec 03, 2007 at 12:59 UTC |