Merge pull request #951 from facebook/lastBlock
saves 3-bytes on small input with streaming API
This commit is contained in:
@@ -2535,7 +2535,8 @@ static size_t ZSTD_resetCStream_internal(ZSTD_CStream* zcs,
|
||||
|
||||
zcs->inToCompress = 0;
|
||||
zcs->inBuffPos = 0;
|
||||
zcs->inBuffTarget = zcs->blockSize;
|
||||
zcs->inBuffTarget = zcs->blockSize
|
||||
+ (zcs->blockSize == pledgedSrcSize); /* for small input: avoid automatic flush on reaching end of block, since it would require to add a 3-bytes null block to end frame */
|
||||
zcs->outBuffContentSize = zcs->outBuffFlushedSize = 0;
|
||||
zcs->streamStage = zcss_load;
|
||||
zcs->frameEnded = 0;
|
||||
@@ -2687,9 +2688,9 @@ size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
|
||||
/* check expectations */
|
||||
DEBUGLOG(5, "ZSTD_compressStream_generic, flush=%u", (U32)flushMode);
|
||||
assert(zcs->inBuff != NULL);
|
||||
assert(zcs->inBuffSize>0);
|
||||
assert(zcs->outBuff!= NULL);
|
||||
assert(zcs->outBuffSize>0);
|
||||
assert(zcs->inBuffSize > 0);
|
||||
assert(zcs->outBuff != NULL);
|
||||
assert(zcs->outBuffSize > 0);
|
||||
assert(output->pos <= output->size);
|
||||
assert(input->pos <= input->size);
|
||||
|
||||
|
||||
+5
-1
@@ -126,6 +126,10 @@ $ZSTD -d > $INTOVOID && die "should have refused : compressed data from terminal
|
||||
fi
|
||||
$ECHO "test : null-length file roundtrip"
|
||||
$ECHO -n '' | $ZSTD - --stdout | $ZSTD -d --stdout
|
||||
$ECHO "test : ensure small file doesn't add 3-bytes null block"
|
||||
./datagen -g1 > tmp1
|
||||
$ZSTD tmp1 -c | wc -c | grep "14"
|
||||
$ZSTD < tmp1 | wc -c | grep "14"
|
||||
$ECHO "test : decompress file with wrong suffix (must fail)"
|
||||
$ZSTD -d tmpCompressed && die "wrong suffix error not detected!"
|
||||
$ZSTD -df tmp && die "should have refused : wrong extension"
|
||||
@@ -324,7 +328,7 @@ $DIFF $TESTFILE result
|
||||
if [ -n "$hasMT" ]
|
||||
then
|
||||
$ECHO "- Test dictionary compression with multithreading "
|
||||
./datagen -g5M | $ZSTD -T2 -D tmpDict | $ZSTD -t -D tmpDict # fails with v1.3.2
|
||||
./datagen -g5M | $ZSTD -T2 -D tmpDict | $ZSTD -t -D tmpDict # fails with v1.3.2
|
||||
fi
|
||||
$ECHO "- Create second (different) dictionary "
|
||||
$ZSTD --train *.c ../programs/*.c ../programs/*.h -o tmpDictC
|
||||
|
||||
Reference in New Issue
Block a user