
This is about 10% faster on a Pentium: { for(const char* p = str_value; size; ++p, --size) { Jonathan Brannan wrote:
we have found that atoi/strtol/strtoll/strtod are slow compared to the optimized output (gcc -O2/3) of a very simple * 10 loop. The C number converters work for a large varity of bases, which makes them slower than needed for base 10.
we use something like:
template<typename TInteger> bool validated_to_unsigned_int( const char* str_value, size_t size, TInteger& result) { size_t i = 0; for(const char* p = str_value; i < size; ++p, ++i) { char digit = *p; if (digit >= '0' && digit <='9') { result = result * 10 + digit - '0'; } else { return false; } } return true; }
with wrappers for signed and ones that throw exceptions. We have a few converters that are faster, but only without error checking (base 16 conversion with lookup table works for small numbers, for example) _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost