stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Farid_Zari...@epam.com>
Subject RE: svn commit: r605548 - in /incubator/stdcxx/branches/4.2.x/include: rw/_defs.h rw/_specialized.h sstream string
Date Wed, 19 Dec 2007 17:01:21 GMT
> -----Original Message-----
> From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor
> Sent: Wednesday, December 19, 2007 6:27 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r605548 - in 
> /incubator/stdcxx/branches/4.2.x/include: rw/_defs.h 
> rw/_specialized.h sstream string

> incubator/stdcxx/branches/4.2.x/include/rw/_specialized.h Wed Dec 
> > +++ 19 06:19:33 2007
> > @@ -69,8 +69,12 @@
> >  {
> >      typedef _RWSTD_CONTAINER_SIZE_TYPE _RWSizeT;
> >  
> > -    _RWSizeT __cap = _RWSTD_STATIC_CAST (_RWSizeT,
> > -                                       __size * 
> _RWSTD_NEW_CAPACITY_RATIO);
> > +    const _RWSizeT __ratio = _RWSizeT (  
> (_RWSTD_NEW_CAPACITY_RATIO << 10)
> > +                                       / _RWSTD_RATIO_DIVIDER);
> > +
> > +    const _RWSizeT __cap =   (__size >> 10) * __ratio
> > +                           + (((__size & 0x3ff) * __ratio) >> 10);
> > +
> 
> Sorry to bringing this up only now that you've committed it...
> 
> Would it make sense to make __ratio a global macro instead of 
> repeating the same computation in several places?

  But we have two __ratio's: __ratio for _RWSTD_NEW_CAPACITY_RATIO
and __ratio for _RWSTD_STRING_CAPACITY_RATIO.

> Also, since 
> the divider is used only in the computation of the ratio and 
> since we're hardcoding the 10 in the left shift, it sees we 
> might as well hardcode the 1000 and forget the divider.

  The 10 in left shift is related to the ">> 10" and "& 0x3ff"
operations, but 1000 value is independent from them.
We can define _RWSTD_NEW_CAPACITY_RATIO as 16180
and use 10000 instead of 1000 (i.e. if the _RWSTD_NEW_CAPACITY_RATIO
will contain the 5 significant digits).

  Are we need the possibility to change the _RWSTD_NEW_CAPACITY
value to some other? Or we can assume that this value is fixed?

Farid.

Mime
View raw message