Julian Foad wrote:
> THE "STRING" CLASS IS VERY EFFICIENT!

This is only sort of true.  The string class is as efficient a
general-purpose, arbitrary-length, arbitrary-lifespan data handler
library as you can find. :)

The problem is that such a beast is just going to be slow, period.
Returning a string from a function requires that it be allocated in
the heap, used, and then thrown back into the heap immediately.
That's a round trip through the memory allocator for every such
function call, which is going to be much, much slower than returning a
static pointer.  This is not surprising, because it's also much more
robust than returning a static pointer.

I'm not sure that there's a good answer here.  We could consider
"interning" constant strings like property paths into constant
references that don't need allocation.  But stuff like
getStringValue() is always going to have to allocate a new string if
we want to do this robustly.

Andy

-- 
Andrew J. Ross                NextBus Information Systems
Senior Software Engineer      Emeryville, CA
[EMAIL PROTECTED]              http://www.nextbus.com
"Men go crazy in conflagrations.  They only get better one by one."
 - Sting (misquoted)


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to