Branch: Tag:

2014-09-14

2014-09-14 13:40:56 by Stephen R. van den Berg <srb@cuci.nl>

Simplify code, speed up fast path.

579:       static LONGEST io_read_number( IOBuffer *io, size_t len )    { -  size_t i; +     LONGEST res;    if( !io_avail(io, len) )    return -1; -  if( len > SIZEOF_INT_TYPE ) -  { -  unsigned int extra = len-SIZEOF_INT_TYPE; -  /* ensure only 0:s */ -  for( i=0; i<extra; i++ ) -  { -  if( io_read_byte_uc(io) ) +  /* ensure only leading 0:s */ +  for (; UNLIKELY(len > SIZEOF_INT_TYPE); len--) +  if( UNLIKELY(io_read_byte_uc(io)) )    Pike_error("Integer (%dbit) overflow.\n", SIZEOF_INT_TYPE*8); -  } -  len=SIZEOF_INT_TYPE; -  } -  if( len == SIZEOF_INT_TYPE ) -  { -  if( *io_read_pointer(io) > 127 ) +  +  res = io_read_number_uc( io, len ); +  +  if ( UNLIKELY(res < 0) )    Pike_error("Signed (%dbit) overflow.\n", SIZEOF_INT_TYPE*8); -  +  return res;    } -  return io_read_number_uc( io, len ); -  } +        static struct object *io_read_bignum( IOBuffer *io, size_t len )    {