This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: strtoul etc.
- To: libstdc++@sourceware.cygnus.com
- Subject: Re: strtoul etc.
- From: Nathan Myers <ncm@cantrip.org>
- Date: Thu, 6 May 1999 12:36:05 -0700
Ulrich wrote:
> Nathan Myers <ncm@cantrip.org> writes:
>
> > Using the strtoul() family for conversion is just wrong.
>
> It's not. It's memory efficient and fast. Note that the base
> parameter is not 0.
Yes, strtoul is about the fastest way to do what its spec says.
However, that spec is not appropriate for what iostream needs.
> If you implemented strtoll etc *fast* you'd know how much work it is.
I know it is a lot of work. That's not the point.
> > While filling the buffer to pass to strtoul, you have already
> > done all of its work except for the most trivial part -- a
> > multiply-and-add.
>
> See. You don't even see the real problem.
The problem is that using strtoul() means the iostream function
must do most of the same work as is done by strtoul in order to
construct input suitable for strtoul.
There is nothing wrong with using strtoul in C code which happens
to have what strtoul is intended to convert. Iostream is not such
code, and the amount of work it must to to *correctly* convert to
strtoul's requirements is as large as, or larger than, the amount
of work strtoul does; furthermore, it must duplicate much of what
strtoul does and then discard the results. This is necessarily
(a lot) slower than integrating the operations into iostream.
Nathan Myers
ncm@cantrip.org