summaryrefslogtreecommitdiff
path: root/inffast.c
diff options
context:
space:
mode:
authorSebastian Pop <s.pop@samsung.com>2019-03-06 14:16:20 -0600
committerHans Kristian Rosbach <hk-github@circlestorm.org>2019-03-21 11:22:36 +0100
commit20ca64fa5d2d8a7421ed86b68709ef971dcfbddf (patch)
treed166e9554dc24f8715614976c31ec5b3b0798134 /inffast.c
parenta1d4af095bef56c42b168ebdb53b545af8f82c5f (diff)
define and use chunkmemset instead of byte_memset for INFFAST_CHUNKSIZE
Diffstat (limited to 'inffast.c')
-rw-r--r--inffast.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/inffast.c b/inffast.c
index 045242a..f2811ef 100644
--- a/inffast.c
+++ b/inffast.c
@@ -262,18 +262,10 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) {
if (op < len) { /* still need some from output */
len -= op;
out = chunkcopysafe(out, from, op, safe);
- if (dist == 1) {
- out = byte_memset(out, len);
- } else {
- out = chunkunroll(out, &dist, &len);
- out = chunkcopysafe(out, out - dist, len, safe);
- }
+ out = chunkunroll(out, &dist, &len);
+ out = chunkcopysafe(out, out - dist, len, safe);
} else {
- if (from - out == 1) {
- out = byte_memset(out, len);
- } else {
- out = chunkcopysafe(out, from, len, safe);
- }
+ out = chunkcopysafe(out, from, len, safe);
}
#else
from = window;
@@ -319,18 +311,16 @@ void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) {
#endif
} else {
#ifdef INFFAST_CHUNKSIZE
- if (dist == 1 && len >= sizeof(uint64_t)) {
- out = byte_memset(out, len);
- } else {
- /* Whole reference is in range of current output. No
- range checks are necessary because we start with room
- for at least 258 bytes of output, so unroll and roundoff
- operations can write beyond `out+len` so long as they
- stay within 258 bytes of `out`.
- */
- out = chunkunroll(out, &dist, &len);
+ /* Whole reference is in range of current output. No
+ range checks are necessary because we start with room
+ for at least 258 bytes of output, so unroll and roundoff
+ operations can write beyond `out+len` so long as they
+ stay within 258 bytes of `out`.
+ */
+ if (dist >= len || dist >= INFFAST_CHUNKSIZE)
out = chunkcopy(out, out - dist, len);
- }
+ else
+ out = chunkmemset(out, dist, len);
#else
if (len < sizeof(uint64_t))
out = set_bytes(out, out - dist, dist, len);