diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-08 16:44:45 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-08 16:44:45 +0200 |
commit | 87a08e476b38ec9ac4ee93c34599b24a7bb284d9 (patch) | |
tree | 59cfdf6458ed39eb6fdb79c88cccffef2da5065f /archival/lzop.c | |
parent | 3d4f688a1907c80678d3f0ed4bc4fd9f99b9a63b (diff) | |
download | busybox-w32-87a08e476b38ec9ac4ee93c34599b24a7bb284d9.tar.gz busybox-w32-87a08e476b38ec9ac4ee93c34599b24a7bb284d9.tar.bz2 busybox-w32-87a08e476b38ec9ac4ee93c34599b24a7bb284d9.zip |
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>
Diffstat (limited to '')
-rw-r--r-- | archival/lzop.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/archival/lzop.c b/archival/lzop.c index b6a3cca09..8f604254c 100644 --- a/archival/lzop.c +++ b/archival/lzop.c | |||
@@ -641,12 +641,20 @@ static NOINLINE int lzo_compress(const header_t *h) | |||
641 | uint32_t d_crc32 = CRC32_INIT_VALUE; | 641 | uint32_t d_crc32 = CRC32_INIT_VALUE; |
642 | uint8_t *wrk_mem = NULL; | 642 | uint8_t *wrk_mem = NULL; |
643 | 643 | ||
644 | /* Only these methods are possible, see lzo_set_method(): | ||
645 | * -1: M_LZO1X_1_15 | ||
646 | * -2..6: M_LZO1X_1 | ||
647 | * -7..9: M_LZO1X_999 if ENABLE_LZOP_COMPR_HIGH | ||
648 | */ | ||
644 | if (h->method == M_LZO1X_1) | 649 | if (h->method == M_LZO1X_1) |
645 | wrk_mem = xzalloc(LZO1X_1_MEM_COMPRESS); | 650 | wrk_mem = xzalloc(LZO1X_1_MEM_COMPRESS); |
646 | else if (h->method == M_LZO1X_1_15) | 651 | else /* check only if it's not the only possibility */ |
647 | wrk_mem = xzalloc(LZO1X_1_15_MEM_COMPRESS); | 652 | IF_LZOP_COMPR_HIGH(if (h->method == M_LZO1X_1_15)) |
648 | else if (h->method == M_LZO1X_999) | 653 | wrk_mem = xzalloc(LZO1X_1_15_MEM_COMPRESS); |
654 | #if ENABLE_LZOP_COMPR_HIGH | ||
655 | else /* must be h->method == M_LZO1X_999 */ | ||
649 | wrk_mem = xzalloc(LZO1X_999_MEM_COMPRESS); | 656 | wrk_mem = xzalloc(LZO1X_999_MEM_COMPRESS); |
657 | #endif | ||
650 | 658 | ||
651 | for (;;) { | 659 | for (;;) { |
652 | unsigned src_len, dst_len; | 660 | unsigned src_len, dst_len; |
@@ -675,16 +683,13 @@ static NOINLINE int lzo_compress(const header_t *h) | |||
675 | /* compress */ | 683 | /* compress */ |
676 | if (h->method == M_LZO1X_1) | 684 | if (h->method == M_LZO1X_1) |
677 | r = lzo1x_1_compress(b1, src_len, b2, &dst_len, wrk_mem); | 685 | r = lzo1x_1_compress(b1, src_len, b2, &dst_len, wrk_mem); |
678 | else if (h->method == M_LZO1X_1_15) | 686 | else IF_LZOP_COMPR_HIGH(if (h->method == M_LZO1X_1_15)) |
679 | r = lzo1x_1_15_compress(b1, src_len, b2, &dst_len, wrk_mem); | 687 | r = lzo1x_1_15_compress(b1, src_len, b2, &dst_len, wrk_mem); |
680 | #if ENABLE_LZOP_COMPR_HIGH | 688 | #if ENABLE_LZOP_COMPR_HIGH |
681 | else if (h->method == M_LZO1X_999) | 689 | else /* must be h->method == M_LZO1X_999 */ |
682 | r = lzo1x_999_compress_level(b1, src_len, b2, &dst_len, | 690 | r = lzo1x_999_compress_level(b1, src_len, b2, &dst_len, |
683 | wrk_mem, h->level); | 691 | wrk_mem, h->level); |
684 | #endif | 692 | #endif |
685 | else | ||
686 | bb_error_msg_and_die("internal error"); | ||
687 | |||
688 | if (r != 0) /* not LZO_E_OK */ | 693 | if (r != 0) /* not LZO_E_OK */ |
689 | bb_error_msg_and_die("%s: %s", "internal error", "compression"); | 694 | bb_error_msg_and_die("%s: %s", "internal error", "compression"); |
690 | 695 | ||
@@ -1025,25 +1030,27 @@ static int read_header(header_t *h) | |||
1025 | /**********************************************************************/ | 1030 | /**********************************************************************/ |
1026 | static void lzo_set_method(header_t *h) | 1031 | static void lzo_set_method(header_t *h) |
1027 | { | 1032 | { |
1028 | int level = 1; | 1033 | smallint level; |
1034 | |||
1035 | /* levels 2..6 or none (defaults to level 3) */ | ||
1036 | h->method = M_LZO1X_1; | ||
1037 | level = 5; /* levels 2-6 are actually the same */ | ||
1029 | 1038 | ||
1030 | if (option_mask32 & OPT_1) { | 1039 | if (option_mask32 & OPT_1) { |
1031 | h->method = M_LZO1X_1_15; | 1040 | h->method = M_LZO1X_1_15; |
1032 | } else if (option_mask32 & OPT_789) { | 1041 | level = 1; |
1042 | } | ||
1043 | if (option_mask32 & OPT_789) { | ||
1033 | #if ENABLE_LZOP_COMPR_HIGH | 1044 | #if ENABLE_LZOP_COMPR_HIGH |
1034 | h->method = M_LZO1X_999; | 1045 | h->method = M_LZO1X_999; |
1046 | level = 9; | ||
1035 | if (option_mask32 & OPT_7) | 1047 | if (option_mask32 & OPT_7) |
1036 | level = 7; | 1048 | level = 7; |
1037 | else if (option_mask32 & OPT_8) | 1049 | else if (option_mask32 & OPT_8) |
1038 | level = 8; | 1050 | level = 8; |
1039 | else | ||
1040 | level = 9; | ||
1041 | #else | 1051 | #else |
1042 | bb_error_msg_and_die("high compression not compiled in"); | 1052 | bb_error_msg_and_die("high compression not compiled in"); |
1043 | #endif | 1053 | #endif |
1044 | } else { /* levels 2..6 or none (defaults to level 3) */ | ||
1045 | h->method = M_LZO1X_1; | ||
1046 | level = 5; /* levels 2-6 are actually the same */ | ||
1047 | } | 1054 | } |
1048 | 1055 | ||
1049 | h->level = level; | 1056 | h->level = level; |