pike.git / src / modules / _Stdio / buffer.cmod

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:222:    * It is actually not certain that checking this is a good idea.    *    * The reason being that if the current buffer size is very small    * (io_len(io)) and the bytes added is large and there is an    * offset, it makes sense to move now when we do not have to copy    * as much.    *    */    if( LIKELY(!io->locked_move) )    { -  if( UNLIKELY((force && io->offset) || (io->offset > io->len)) ) +  if( UNLIKELY((force && io->offset) || (io_len(io) && io->offset > io->allocated / 2)) )    {    /* more than 50% of the buffer is available before the read pointer,    * and we can discard that data. Move the data to the beginning, making    * room for more data. -  +  * +  * NOTE: since the empty space at the beginning is bigger than half of the full +  * allocated space, src and dst do not overlap. We can therefore use memcpy().    */ -  memmove( io->buffer, io_read_pointer(io), io_len(io) ); +  memcpy( io->buffer, io_read_pointer(io), io_len(io) );    io->num_move++;    io->len -= io->offset;    io->offset = 0;    }    }       if( UNLIKELY(io->len + bytes > io->allocated) )    {    /* Actually grow the buffer. */    size_t growth =