summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2015-05-07 18:58:11 +0100
committerFrediano Ziglio <fziglio@redhat.com>2016-01-27 18:39:06 +0000
commit75cb2701d33bf49887e0f9175b2c42e56047e7e7 (patch)
treec7a85d14d6ae101168d638ba94863356ecc2501b /common
parent580adf7c36d07bc9cb8bcb4092fea3dea3ec361c (diff)
downloadspice-common-75cb2701d33bf49887e0f9175b2c42e56047e7e7.tar.gz
spice-common-75cb2701d33bf49887e0f9175b2c42e56047e7e7.tar.xz
spice-common-75cb2701d33bf49887e0f9175b2c42e56047e7e7.zip
Use code to compute a bit mask
Code is in the slow path, this reduce space needed for data+code. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Diffstat (limited to 'common')
-rw-r--r--common/quic.c13
1 files 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];