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.
  • IOBuffer vs. Buffe... Stephen R. van den Berg
    • Re: IOBuffer ... Stephen R. van den Berg
      • Re: IOBuf... Stephen R. van den Berg
        • Re: I... Per Hedbor () @ Pike (-) developers forum
      • Re: IOBuf... Stephen R. van den Berg
        • Re: I... Arne Goedeke
          • R... Stephen R. van den Berg
            • ... Per Hedbor () @ Pike (-) developers forum
              • ... Per Hedbor () @ Pike (-) developers forum
                • ... Per Hedbor () @ Pike (-) developers forum
                • ... Peter Bortas @ Pike developers forum
                • ... Per Hedbor () @ Pike (-) developers forum
                • ... Henrik Grubbstr�m (Lysator) @ Pike (-) developers forum
                • ... Per Hedbor () @ Pike (-) developers forum
                • ... Per Hedbor () @ Pike (-) developers forum
      • Re: IOBuf... Per Hedbor () @ Pike (-) developers forum
    • IOBuffer vs. ... Per Hedbor () @ Pike (-) developers forum

Reply via email to