aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/lzma
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2020-02-21 17:40:02 +0200
committerLasse Collin <lasse.collin@tukaani.org>2020-02-21 17:40:02 +0200
commit43dfe04e6209c691cf4fbe3072d4ee91271748f1 (patch)
tree192ffefdae17f324cf29cd0a818eb7576d8c0fd3 /src/liblzma/lzma
parentBuild: Add visibility.m4 from gnulib. (diff)
downloadxz-43dfe04e6209c691cf4fbe3072d4ee91271748f1.tar.xz
liblzma: Add more uses of lzma_memcmplen() to the normal mode of LZMA.
This gives a tiny encoder speed improvement. This could have been done in 2014 after the commit 544aaa3d13554e8640f9caf7db717a96360ec0f6 but it was forgotten.
Diffstat (limited to 'src/liblzma/lzma')
-rw-r--r--src/liblzma/lzma/lzma_encoder_optimum_normal.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/liblzma/lzma/lzma_encoder_optimum_normal.c b/src/liblzma/lzma/lzma_encoder_optimum_normal.c
index 59f77343..101c8d47 100644
--- a/src/liblzma/lzma/lzma_encoder_optimum_normal.c
+++ b/src/liblzma/lzma/lzma_encoder_optimum_normal.c
@@ -636,9 +636,10 @@ helper2(lzma_lzma1_encoder *coder, uint32_t *reps, const uint8_t *buf,
uint32_t len_test_2 = len_test + 1;
const uint32_t limit = my_min(buf_avail_full,
len_test_2 + nice_len);
- for (; len_test_2 < limit
- && buf[len_test_2] == buf_back[len_test_2];
- ++len_test_2) ;
+ // NOTE: len_test_2 may be greater than limit so the call to
+ // lzma_memcmplen() must be done conditionally.
+ if (len_test_2 < limit)
+ len_test_2 = lzma_memcmplen(buf, buf_back, len_test_2, limit);
len_test_2 -= len_test + 1;
@@ -732,9 +733,12 @@ helper2(lzma_lzma1_encoder *coder, uint32_t *reps, const uint8_t *buf,
const uint32_t limit = my_min(buf_avail_full,
len_test_2 + nice_len);
- for (; len_test_2 < limit &&
- buf[len_test_2] == buf_back[len_test_2];
- ++len_test_2) ;
+ // NOTE: len_test_2 may be greater than limit
+ // so the call to lzma_memcmplen() must be
+ // done conditionally.
+ if (len_test_2 < limit)
+ len_test_2 = lzma_memcmplen(buf, buf_back,
+ len_test_2, limit);
len_test_2 -= len_test + 1;