> 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.
Not really, we are in /a/ buffer object, not the subsection of it that should be returned. You have to create a new one to return a subsection. read_buffer is about as fast as it gets, it does the minimal amount of work. > 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. Nothing that adds data to the buffer returns a string in the current buffer code. The only thing that returns a string is if you call read() or read_hstring() on it. -- Per