You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2006/11/03 01:15:51 UTC

Re: svn commit: r465512 - /incubator/stdcxx/trunk/include/bitset.cc

faridz@apache.org wrote:
> Author: faridz
> Date: Wed Oct 18 23:53:06 2006
> New Revision: 465512
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=465512
> Log:
> 2006-10-19 Farid Zaripov <fa...@kyiv.vdiweb.com>
> 
> 	STDCXX-297
> 	* bitset.cc (__rw_bitset): Corrected calculation of
> 	size of the __bits buffer

I think the logic should be factored out into a function,
say __rw_bits_to_bytes, defined in bitset.cpp. That will
allow us to reduce the complexity of the code here (making
it smaller and faster to compile) while at the same time
letting us reuse the same logic in the char and wchar_t
overloads defined in bitset.cpp.

Martin

Re: svn commit: r465512 - /incubator/stdcxx/trunk/include/bitset.cc

Posted by Martin Sebor <se...@roguewave.com>.
Martin Sebor wrote:
> faridz@apache.org wrote:
> 
>> Author: faridz
>> Date: Wed Oct 18 23:53:06 2006
>> New Revision: 465512
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=465512
>> Log:
>> 2006-10-19 Farid Zaripov <fa...@kyiv.vdiweb.com>
>>
>>     STDCXX-297
>>     * bitset.cc (__rw_bitset): Corrected calculation of
>>     size of the __bits buffer
> 
> 
> I think the logic should be factored out into a function,
> say __rw_bits_to_bytes, defined in bitset.cpp.

Or maybe even __rw_bit_clear since, AFAICS, the only thing
the computed value is used for is a call to memset().

Another option would be to change __rw_shl() (as well as
__rw_shr()) to take the number of bits rather than bytes
as their second argument and have them do the computation.
Then we could call __rw_shl() (or __rw_shr()) to quickly
set all the bits to zero by shifting the bitset more than
the number of bits it contains.

Martin

> That will
> allow us to reduce the complexity of the code here (making
> it smaller and faster to compile) while at the same time
> letting us reuse the same logic in the char and wchar_t
> overloads defined in bitset.cpp.
> 
> Martin