summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenys Vlasenko2018-04-08 16:44:45 +0200
committerDenys Vlasenko2018-04-08 16:44:45 +0200
commit87a08e476b38ec9ac4ee93c34599b24a7bb284d9 (patch)
tree59cfdf6458ed39eb6fdb79c88cccffef2da5065f /archival
parent3d4f688a1907c80678d3f0ed4bc4fd9f99b9a63b (diff)
downloadbusybox-87a08e476b38ec9ac4ee93c34599b24a7bb284d9.zip
busybox-87a08e476b38ec9ac4ee93c34599b24a7bb284d9.tar.gz
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 'archival')
-rw-r--r--archival/lzop.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/archival/lzop.c b/archival/lzop.c
index b6a3cca..8f60425 100644
--- a/archival/lzop.c
+++ b/archival/lzop.c
@@ -641,12 +641,20 @@ static NOINLINE int lzo_compress(const header_t *h)
uint32_t d_crc32 = CRC32_INIT_VALUE;
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)
wrk_mem = xzalloc(LZO1X_1_MEM_COMPRESS);
- else if (h->method == M_LZO1X_1_15)
- wrk_mem = xzalloc(LZO1X_1_15_MEM_COMPRESS);
- else if (h->method == M_LZO1X_999)
+ else /* check only if it's not the only possibility */
+ IF_LZOP_COMPR_HIGH(if (h->method == M_LZO1X_1_15))
+ 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);
+#endif
for (;;) {
unsigned src_len, dst_len;
@@ -675,16 +683,13 @@ static NOINLINE int lzo_compress(const header_t *h)
/* compress */
if (h->method == M_LZO1X_1)
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);
#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,
wrk_mem, h->level);
#endif
- else
- bb_error_msg_and_die("internal error");
-
if (r != 0) /* not LZO_E_OK */
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)
{
- 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) {
h->method = M_LZO1X_1_15;
- } else if (option_mask32 & OPT_789) {
+ level = 1;
+ }
+ if (option_mask32 & OPT_789) {
#if ENABLE_LZOP_COMPR_HIGH
h->method = M_LZO1X_999;
+ level = 9;
if (option_mask32 & OPT_7)
level = 7;
else if (option_mask32 & OPT_8)
level = 8;
- else
- level = 9;
#else
bb_error_msg_and_die("high compression not compiled in");
#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;