[Spice-devel] [PATCH 5/5] Use code to compute a bit mask

Jonathon Jongsma jjongsma at redhat.com
Wed Jan 27 09:43:55 PST 2016


Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

On Wed, 2016-01-27 at 16:09 +0000, Frediano Ziglio wrote:
> Code is in the slow path, this reduce space needed for data+code.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  common/quic.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/common/quic.c b/common/quic.c
> index a32a530..88cf143 100644
> --- a/common/quic.c
> +++ b/common/quic.c
> @@ -194,16 +194,7 @@ static const unsigned long int bppmask[33] = {
>      0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff /* [32] */
>  };
>  
> -static const unsigned int bitat[32] = {
> -    0x00000001, 0x00000002, 0x00000004, 0x00000008,
> -    0x00000010, 0x00000020, 0x00000040, 0x00000080,
> -    0x00000100, 0x00000200, 0x00000400, 0x00000800,
> -    0x00001000, 0x00002000, 0x00004000, 0x00008000,
> -    0x00010000, 0x00020000, 0x00040000, 0x00080000,
> -    0x00100000, 0x00200000, 0x00400000, 0x00800000,
> -    0x01000000, 0x02000000, 0x04000000, 0x08000000,
> -    0x10000000, 0x20000000, 0x40000000, 0x80000000 /* [31]*/
> -};
> +#define bitat(n) (1u<<(n))
>  
>  
>  #define TABRAND_TABSIZE 256
> @@ -371,7 +362,7 @@ static void golomb_coding_slow(QuicFamily *family, const
> BYTE n, const unsigned
>                                 unsigned int * const codewordlen)
>  {
>      if (n < family->nGRcodewords[l]) {
> -        (*codeword) = bitat[l] | (n & bppmask[l]);
> +        (*codeword) = bitat(l) | (n & bppmask[l]);
>          (*codewordlen) = (n >> l) + l + 1;
>      } else {
>          (*codeword) = n - family->nGRcodewords[l];


More information about the Spice-devel mailing list