lzop: remove method checks which are always true/false

function                                             old     new   delta
do_lzo_compress                                      232     224      -8
lzo_compress                                         531     488     -43
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-51)             Total: -51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-04-08 16:44:45 +02:00
parent 3d4f688a19
commit 87a08e476b

View File

@ -641,12 +641,20 @@ static NOINLINE int lzo_compress(const header_t *h)
uint32_t d_crc32 = CRC32_INIT_VALUE; uint32_t d_crc32 = CRC32_INIT_VALUE;
uint8_t *wrk_mem = NULL; uint8_t *wrk_mem = NULL;
/* Only these methods are possible, see lzo_set_method():
* -1: M_LZO1X_1_15
* -2..6: M_LZO1X_1
* -7..9: M_LZO1X_999 if ENABLE_LZOP_COMPR_HIGH
*/
if (h->method == M_LZO1X_1) if (h->method == M_LZO1X_1)
wrk_mem = xzalloc(LZO1X_1_MEM_COMPRESS); wrk_mem = xzalloc(LZO1X_1_MEM_COMPRESS);
else if (h->method == M_LZO1X_1_15) else /* check only if it's not the only possibility */
wrk_mem = xzalloc(LZO1X_1_15_MEM_COMPRESS); IF_LZOP_COMPR_HIGH(if (h->method == M_LZO1X_1_15))
else if (h->method == M_LZO1X_999) wrk_mem = xzalloc(LZO1X_1_15_MEM_COMPRESS);
#if ENABLE_LZOP_COMPR_HIGH
else /* must be h->method == M_LZO1X_999 */
wrk_mem = xzalloc(LZO1X_999_MEM_COMPRESS); wrk_mem = xzalloc(LZO1X_999_MEM_COMPRESS);
#endif
for (;;) { for (;;) {
unsigned src_len, dst_len; unsigned src_len, dst_len;
@ -675,16 +683,13 @@ static NOINLINE int lzo_compress(const header_t *h)
/* compress */ /* compress */
if (h->method == M_LZO1X_1) if (h->method == M_LZO1X_1)
r = lzo1x_1_compress(b1, src_len, b2, &dst_len, wrk_mem); r = lzo1x_1_compress(b1, src_len, b2, &dst_len, wrk_mem);
else if (h->method == M_LZO1X_1_15) else IF_LZOP_COMPR_HIGH(if (h->method == M_LZO1X_1_15))
r = lzo1x_1_15_compress(b1, src_len, b2, &dst_len, wrk_mem); r = lzo1x_1_15_compress(b1, src_len, b2, &dst_len, wrk_mem);
#if ENABLE_LZOP_COMPR_HIGH #if ENABLE_LZOP_COMPR_HIGH
else if (h->method == M_LZO1X_999) else /* must be h->method == M_LZO1X_999 */
r = lzo1x_999_compress_level(b1, src_len, b2, &dst_len, r = lzo1x_999_compress_level(b1, src_len, b2, &dst_len,
wrk_mem, h->level); wrk_mem, h->level);
#endif #endif
else
bb_error_msg_and_die("internal error");
if (r != 0) /* not LZO_E_OK */ if (r != 0) /* not LZO_E_OK */
bb_error_msg_and_die("%s: %s", "internal error", "compression"); bb_error_msg_and_die("%s: %s", "internal error", "compression");
@ -1025,25 +1030,27 @@ static int read_header(header_t *h)
/**********************************************************************/ /**********************************************************************/
static void lzo_set_method(header_t *h) static void lzo_set_method(header_t *h)
{ {
int level = 1; smallint level;
/* levels 2..6 or none (defaults to level 3) */
h->method = M_LZO1X_1;
level = 5; /* levels 2-6 are actually the same */
if (option_mask32 & OPT_1) { if (option_mask32 & OPT_1) {
h->method = M_LZO1X_1_15; h->method = M_LZO1X_1_15;
} else if (option_mask32 & OPT_789) { level = 1;
}
if (option_mask32 & OPT_789) {
#if ENABLE_LZOP_COMPR_HIGH #if ENABLE_LZOP_COMPR_HIGH
h->method = M_LZO1X_999; h->method = M_LZO1X_999;
level = 9;
if (option_mask32 & OPT_7) if (option_mask32 & OPT_7)
level = 7; level = 7;
else if (option_mask32 & OPT_8) else if (option_mask32 & OPT_8)
level = 8; level = 8;
else
level = 9;
#else #else
bb_error_msg_and_die("high compression not compiled in"); bb_error_msg_and_die("high compression not compiled in");
#endif #endif
} else { /* levels 2..6 or none (defaults to level 3) */
h->method = M_LZO1X_1;
level = 5; /* levels 2-6 are actually the same */
} }
h->level = level; h->level = level;