FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/id.c
/** Like strtol but with a fixed base of 10, locale independent and limited
 * to non-negative values.  Overflows are indicated by a FALSE return value
 * in which case *RESULT_P will not be modified.
 *
 * This allows the compiler to generate massively faster code.
 * (E.g. Avoiding locale specific processing).  ID parsing is one of the
 * most CPU consuming parts of FSFS data access.  Better be quick.
 */
Like strtol but with a fixed base of 10, locale independent and limited
to non-negative values.  Overflows are indicated by a FALSE return value
in which case *RESULT_P will not be modified.

This allows the compiler to generate massively faster code.
.  ID parsing is one of the
most CPU consuming parts of FSFS data access.  Better be quick.
Like strtol but with a fixed base of 10 locale independent and limited to non - negative values . Overflows are indicated by a FALSE return value in which case * RESULT_P will not be modified . This allows the compiler to generate massively faster code . . ID parsing is one of the most CPU consuming parts of FSFS data access . Better be quick .
static svn_boolean_t
locale_independent_strtol(long *result_p,
                          const char* buffer,
                          const char** end)
{
  unsigned long result = 0;
  while (1)
    {
      unsigned long c = (unsigned char)*buffer - (unsigned char)'0';
      unsigned long next;
      if (c > 9)
        break;
      if (result > ULONG_MAX / 10)
        return FALSE;
      next = result * 10 + c;
      if (next < result)
        return FALSE;
      result = next;
      ++buffer;
    }
  *end = buffer;
  if (result > LONG_MAX)
    return FALSE;
  *result_p = (long)result;
  return TRUE;
}
static svn_boolean_t locale_independent_strtol ( long * result_p , const char * buffer , const char * * end ) { unsigned long result = 0 ; while ( 1 ) { unsigned long c = ( unsigned char ) * buffer - ( unsigned char ) ' ' ; unsigned long next ; if ( c > 9 ) break ; if ( result > ULONG_MAX / 10 ) return FALSE ; next = result * 10 + c ; if ( next < result ) return FALSE ; result = next ; ++ buffer ; } * end = buffer ; if ( result > LONG_MAX ) return FALSE ; * result_p = ( long ) result ; return TRUE ; }
Like strtol but with a fixed base of 10, locale independent and limited
 to non-negative values.
Like strtol but with a fixed base of 10 locale independent and limited to non - negative values .
/* We allow positive values only.  We use unsigned arithmetics to get
   * well-defined overflow behavior.  It also happens to allow for a wider
   * range of compiler-side optimizations. */ /* This implies the NUL check. */ /* Overflow check.  Passing this, NEXT can be no more than ULONG_MAX+9
       * before being truncated to ULONG but it still covers 0 .. ULONG_MAX.
       */ /* Overflow check.  In case of an overflow, NEXT is 0..9.
       * In the non-overflow case, RESULT is either >= 10 or RESULT and NEXT
       * are both 0. */