[v3] Print ints directly to streambuf

Nathan Myers ncm-nospam@cantrip.org
Wed Feb 26 00:26:00 GMT 2003


On Tue, Feb 25, 2003 at 01:52:33PM -0800, Richard Henderson wrote:
> On Sat, Feb 22, 2003 at 12:35:08AM -0500, Jerry Quinn wrote:
> > +    _M_estimate_length(_ValueT __v, const ios_base& __io, bool __neg) const
> > +    {
> > +      if (__builtin_expect((__io.flags() & ios_base::basefield) == ios_base::hex, false))
> > +	{
> > +	  size_t  __log16 = 1;
> > +	  while ((__v >>= 4) != 0)
> > +	    { ++__log16; }
> 
>   (sizeof(__v)*CHAR_BIT - __builtin_clz(__v) + 3) / 4
> 
> ?  (Well, with __builtin_clz{,l,ll} chosen appropriately for the
> type of __v.)  You'd also need an early-out check for a zero input.

I wonder how often this is faster.   Probably we can identify targets 
where it is, and add a flag in config.h.  (In practice, most numbers 
are small, although maybe not most hex-formatted numbers.)

Nathan Myers
ncm-nospam@cantrip.org



More information about the Gcc-patches mailing list