On Wed, Aug 19, 2015 at 1:45 PM, Per Hedbor <p...@hedbor.org> wrote:
> In this specific case you could use Stdio.Buffer instead.
>
> Change writeme to be a buffer, then add to it using ->add(string)
>
> In the socket_write function, you only need this:
>
> if( sizeof( con->_writeme ) )
>   con->_writeme->output_to(con->_socket);
>
> This should be O(1) regardless of the buffer size, and in general
> slightly faster than strings even for short:ish buffers.

Presumably with the same check-and-trim behaviour, so it'd look like this:

conn->_writeme->consume(conn->_writeme->output_to(conn->_sock));

But the main problem is that, as far as I know, Stdio.Buffer is
available only in the newer Pikes. I guess it'll have to be guarded
with a #if constant(Stdio.Buffer), but that means maintaining another
code branch. Maybe I'll drop chunked mode in favour of automatically
using Stdio.Buffer if it's available, and just warn people "On Pike
7.8, avoid outputting large amounts of data as it can cause
performance problems".

ChrisA
  • spl... Per Hedbor () @ Pike (-) developers forum
    • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
      • ... Per Hedbor () @ Pike (-) developers forum
        • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
    • ... Chris Angelico
      • ... Per Hedbor
        • ... Chris Angelico
          • ... Per Hedbor
            • ... Chris Angelico

Reply via email to