This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Speeding-up the parsing of integer types


Hi,

so I have got this idea, not at all original, while working on the
time_get members: there I have been able, with an absolutely reasonable
effort to remove an atoi() and a strtol() call, with obvious advantages
for the performance and for the simplicity of the code.

Now I'm staring at the num_get members, and in particular at _M_extract_int:
we are already parsing anyway all the chars, using profitably the numpunct
cache in order to speed up the process but eventually relying on the
various __convert_to_v.

This is at variance with the fast code prepared by Jerry for the num_put
members, which ends up using an itoa hand written from scratch.

It seems to me that we could rather easily put inside _M_extract_int
something like:

__value = __value * __base + (__c - '0');

during the parsing and avoid completely the final __convert_to_v which,
besides the function call overhead, ends up parsing the whole string
again, checks again the digits and so on. Also we could avoid managing
basic_strings.

Only, we have to templatize _M_extract_int on the integer type in order
to use the correct type throughout, but first blush this seems really
straightforward.

Reconsidering what we have achieved for do_get_year:

http://gcc.gnu.org/ml/libstdc++/2003-12/msg00023.html

seems likely an order 3x speed with a moderate programming effort.

What do people think about this small project of mine? In case,
I can start working on it almost immediately.

Thanks,
Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]