incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: [PATCH] bitset.cc (STDCXX-297)
Date Mon, 09 Oct 2006 19:42:31 GMT
Farid Zaripov wrote:
>   Below is a small patch to resolve issue STDCXX-297:

It seems that it would make sense to use the same code here as in
bitset.cpp. I think that one is "more correct" in that it zeroes
out all the words (and not just the minimum number of bytes taken
up by the bitset). Also, I think the code could be simplified as
follows:

   nbytes =   (((maxbits | (sizeof *bits * CHAR_BIT - 1)) >> 5)
            + (0 != (maxbits & (sizeof *bits * CHAR_BIT - 1)))) << 2;

What do you think? (Can we do better?)

Martin

> 
> Index: bitset.cc
> ===================================================================
> --- bitset.cc	(revision 453570)
> +++ bitset.cc	(working copy)
> @@ -52,7 +52,7 @@
>  
>      // compute the number of bytes occupied by `bits'
>      const _RWSTD_SIZE_T __nbytes =
> -        (__maxbits + sizeof *__bits * _RWSTD_CHAR_BIT - 1) /
> _RWSTD_CHAR_BIT;
> +        (__maxbits + _RWSTD_CHAR_BIT - 1) / _RWSTD_CHAR_BIT;
>  
>      _RWSTD_MEMSET (__bits, 0, __nbytes);
>  
> 
> Farid.


Mime
View raw message