Skip to content

Commit f64cd37

Browse files
committed
FEAT: partial crush decompression
1 parent d744cee commit f64cd37

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/core/u-crush.c

+3
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ static inline int get_penalty(int a, int b) {
359359
ctx.bit_count = 0;
360360
ctx.bit_buf = 0;
361361

362+
// allow partial output if specified...
363+
if (limit && size > limit) size = limit;
364+
362365
ser = Make_Binary(size); // output series
363366
buf = BIN_HEAD(ser); // output binary
364367

src/tests/units/compress-test.r3

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ text: {Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempo
175175
--assert text = to string! decompress compress/level text 'crush 1 'crush
176176
--assert text = to string! decompress compress/level text 'crush 2 'crush
177177

178-
; --test-- "CRUSH decompression with specified uncompressed size"
179-
; bin: compress data 'crush
180-
; --assert #{74657374} = decompress/size bin 'crush 4
178+
--test-- "CRUSH decompression with specified uncompressed size"
179+
bin: compress data 'crush
180+
--assert #{74657374} = decompress/size bin 'crush 4
181181

182182
--test-- "CRUSH compression when input is limited"
183183
--assert #{74657374} = decompress compress/part data 'crush 4 'crush

0 commit comments

Comments
 (0)