Arne Goedeke wrote: >Returning the buffer is cheap assuming that you have one already. >Otherwise you have the cost of object creation, which - depending on the >length of the buffer content - will be more expensive than the potential >memcpy.
Erm... We are *in* a Buffer object, so by definition we have one. So returning a readonly-copy with zero-copy effort is easy. It basically delays the creation of the shared string as long as possible. >In what places do you think it would make sense to return a buffer >object instead of a string? As long as one is doing string operations (adding/substracting/matching) Buffer objects are better. Once done with that, the final "result" can/should be a shared string. -- Stephen.
