diff options
author | yalin wang <yalin.wang2010@gmail.com> | 2015-09-09 18:39:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-10 16:29:01 -0400 |
commit | 8b235f2f16a472b8cfc10e8ef1286fcd3331e033 (patch) | |
tree | 833e552d3da36089d23727f25b6e2b133d769eb3 | |
parent | e4e29dc4841d21943bec1bc5378ab421d2320d83 (diff) |
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>
-rw-r--r-- | lib/zlib_deflate/deftree.c | 6 | ||||
-rw-r--r-- | lib/zlib_deflate/defutil.h | 16 |
2 files changed, 3 insertions, 19 deletions
diff --git a/lib/zlib_deflate/deftree.c b/lib/zlib_deflate/deftree.c index ddf348299f24..9b1756b12743 100644 --- a/lib/zlib_deflate/deftree.c +++ b/lib/zlib_deflate/deftree.c | |||
@@ -35,6 +35,7 @@ | |||
35 | /* #include "deflate.h" */ | 35 | /* #include "deflate.h" */ |
36 | 36 | ||
37 | #include <linux/zutil.h> | 37 | #include <linux/zutil.h> |
38 | #include <linux/bitrev.h> | ||
38 | #include "defutil.h" | 39 | #include "defutil.h" |
39 | 40 | ||
40 | #ifdef DEBUG_ZLIB | 41 | #ifdef DEBUG_ZLIB |
@@ -146,7 +147,6 @@ static void send_all_trees (deflate_state *s, int lcodes, int dcodes, | |||
146 | static void compress_block (deflate_state *s, ct_data *ltree, | 147 | static void compress_block (deflate_state *s, ct_data *ltree, |
147 | ct_data *dtree); | 148 | ct_data *dtree); |
148 | static void set_data_type (deflate_state *s); | 149 | static void set_data_type (deflate_state *s); |
149 | static unsigned bi_reverse (unsigned value, int length); | ||
150 | static void bi_windup (deflate_state *s); | 150 | static void bi_windup (deflate_state *s); |
151 | static void bi_flush (deflate_state *s); | 151 | static void bi_flush (deflate_state *s); |
152 | static void copy_block (deflate_state *s, char *buf, unsigned len, | 152 | static void copy_block (deflate_state *s, char *buf, unsigned len, |
@@ -284,7 +284,7 @@ static void tr_static_init(void) | |||
284 | /* The static distance tree is trivial: */ | 284 | /* The static distance tree is trivial: */ |
285 | for (n = 0; n < D_CODES; n++) { | 285 | for (n = 0; n < D_CODES; n++) { |
286 | static_dtree[n].Len = 5; | 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 | static_init_done = 1; | 289 | static_init_done = 1; |
290 | } | 290 | } |
@@ -520,7 +520,7 @@ static void gen_codes( | |||
520 | int len = tree[n].Len; | 520 | int len = tree[n].Len; |
521 | if (len == 0) continue; | 521 | if (len == 0) continue; |
522 | /* Now reverse the bits */ | 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 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", | 525 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", |
526 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); | 526 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); |
diff --git a/lib/zlib_deflate/defutil.h b/lib/zlib_deflate/defutil.h index b640b6402e99..a8c370897c9f 100644 --- a/lib/zlib_deflate/defutil.h +++ b/lib/zlib_deflate/defutil.h | |||
@@ -293,22 +293,6 @@ void zlib_tr_stored_type_only (deflate_state *); | |||
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 | * Flush the bit buffer, keeping at most 7 bits in it. | 296 | * Flush the bit buffer, keeping at most 7 bits in it. |
313 | */ | 297 | */ |
314 | static inline void bi_flush(deflate_state *s) | 298 | static inline void bi_flush(deflate_state *s) |