Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

zlib_deflate/deftree: remove bi_reverse()

Remove bi_reverse() and use generic bitrev32() instead - it should have
better performance on some platforms.

Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

yalin wang and committed by
Linus Torvalds
8b235f2f e4e29dc4

+3 -19
+3 -3
lib/zlib_deflate/deftree.c
··· 35 35 /* #include "deflate.h" */ 36 36 37 37 #include <linux/zutil.h> 38 + #include <linux/bitrev.h> 38 39 #include "defutil.h" 39 40 40 41 #ifdef DEBUG_ZLIB ··· 147 146 static void compress_block (deflate_state *s, ct_data *ltree, 148 147 ct_data *dtree); 149 148 static void set_data_type (deflate_state *s); 150 - static unsigned bi_reverse (unsigned value, int length); 151 149 static void bi_windup (deflate_state *s); 152 150 static void bi_flush (deflate_state *s); 153 151 static void copy_block (deflate_state *s, char *buf, unsigned len, ··· 284 284 /* The static distance tree is trivial: */ 285 285 for (n = 0; n < D_CODES; n++) { 286 286 static_dtree[n].Len = 5; 287 - static_dtree[n].Code = bi_reverse((unsigned)n, 5); 287 + static_dtree[n].Code = bitrev32((u32)n) >> (32 - 5); 288 288 } 289 289 static_init_done = 1; 290 290 } ··· 520 520 int len = tree[n].Len; 521 521 if (len == 0) continue; 522 522 /* Now reverse the bits */ 523 - tree[n].Code = bi_reverse(next_code[len]++, len); 523 + tree[n].Code = bitrev32((u32)(next_code[len]++)) >> (32 - len); 524 524 525 525 Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", 526 526 n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
-16
lib/zlib_deflate/defutil.h
··· 293 293 } 294 294 295 295 /* =========================================================================== 296 - * Reverse the first len bits of a code, using straightforward code (a faster 297 - * method would use a table) 298 - * IN assertion: 1 <= len <= 15 299 - */ 300 - static inline unsigned bi_reverse(unsigned code, /* the value to invert */ 301 - int len) /* its bit length */ 302 - { 303 - register unsigned res = 0; 304 - do { 305 - res |= code & 1; 306 - code >>= 1, res <<= 1; 307 - } while (--len > 0); 308 - return res >> 1; 309 - } 310 - 311 - /* =========================================================================== 312 296 * Flush the bit buffer, keeping at most 7 bits in it. 313 297 */ 314 298 static inline void bi_flush(deflate_state *s)