Commit Graph

158 Commits

Author SHA1 Message Date
W. Felix Handte
59c7d95121 Expose a Faster Stream Reset Function 2018-04-10 13:26:17 -04:00
W. Felix Handte
f88dc90055 Avoid Calling LZ4_prepareTable() in LZ4_compress_fast_continue() 2018-04-09 16:17:33 -04:00
W. Felix Handte
5622c276e1 Return to Allowing Early Returns in LZ4_compress_generic()
Or: `goto` Considered Harmful

Or: https://xkcd.com/292/
2018-04-06 19:28:08 -04:00
Yann Collet
863e24892d fix comment style 2018-03-21 07:07:24 -07:00
W. Felix Handte
66b6fbfe6f Restore the Other Old Streaming Functions in a Degraded Fashion 2018-03-14 15:53:10 -04:00
W. Felix Handte
146e676531 Restore LZ4_sizeofStreamState, We Didn't Actually Need to Delete It 2018-03-13 15:42:03 -04:00
W. Felix Handte
2be38a7429 Rename Enums and Add Comment 2018-03-13 15:16:52 -04:00
W. Felix Handte
b8e9c77855 Whitespace Fixes 2018-03-13 13:20:37 -04:00
W. Felix Handte
5149767a1b Add NULL Checks 2018-03-12 18:35:09 -04:00
W. Felix Handte
299f34909a Simpler Ternary Statements 2018-03-12 18:35:09 -04:00
W. Felix Handte
f9fef255a1 Renames and Comment Fixes 2018-03-12 18:34:41 -04:00
W. Felix Handte
e34716cc3f Preserve currentOffset==0 When Possible 2018-03-12 14:59:28 -04:00
W. Felix Handte
5f8967b983 Specialize _extState() for Clean Ctx Rather Than Calling _safeExtState() 2018-03-12 14:58:43 -04:00
W. Felix Handte
6716325ae8 Remove Switch In Favor of Ternary Statement 2018-03-12 14:58:43 -04:00
W. Felix Handte
b4335a6585 Further Avoid a dictionary==NULL Check 2018-03-12 14:58:43 -04:00
W. Felix Handte
64bcbf400e Optimize Dict Check Condition 2018-03-12 14:58:43 -04:00
W. Felix Handte
b78cf67c96 Move to 4KB Cut-Off 2018-03-12 14:58:43 -04:00
W. Felix Handte
00eadadbfc Reset Table on Inputs Larger than 2KB 2018-03-12 14:58:43 -04:00
W. Felix Handte
d571d0cdba Avoid DictSmall Checks By Strategically Bumping CurrentOffset 2018-03-12 14:58:43 -04:00
W. Felix Handte
1c4601d643 Restore DictIssue Check 2018-03-12 14:58:43 -04:00
W. Felix Handte
d6ed9a7799 Avoid dictionary == NULL Check 2018-03-12 14:58:43 -04:00
W. Felix Handte
efc419a6d4 Replace calloc() Calls With malloc() Where Possible 2018-03-12 14:58:43 -04:00
W. Felix Handte
80790c587b Copy the Dict Table Into the Context for Large Compressions 2018-03-12 14:58:43 -04:00
W. Felix Handte
14ce912b70 Switch Current Offset to 1 Only When in External Dictionary Context Mode 2018-03-12 14:58:43 -04:00
W. Felix Handte
cea09d67a9 Hoist Table Reset One Level Up 2018-03-12 14:58:43 -04:00
W. Felix Handte
68c6bd17b8 Set Dictionary Context Pointer Rather than Copying the Context In 2018-03-12 14:58:43 -04:00
W. Felix Handte
73cc39327e Lookup Matches in Separate Dictionary Context 2018-03-12 14:58:43 -04:00
W. Felix Handte
62cb52b341 Initialize Current Offset to 1 2018-03-12 14:58:43 -04:00
W. Felix Handte
b3628cb0c5 Avoid Resetting the Context When Possible 2018-03-12 14:58:43 -04:00
W. Felix Handte
aa36e118f1 Const-ify Table Arg to LZ4_getPosition(OnHash) 2018-03-12 14:58:43 -04:00
W. Felix Handte
d6a3024dbb Add LZ4_compress_fast_safeExtState Function 2018-03-12 14:58:43 -04:00
W. Felix Handte
5709891de6 Add a Table Type Field to LZ4_stream_t 2018-03-12 14:58:43 -04:00
W. Felix Handte
6933f5ad9c Remove Obsolete Stream Functions to Free Space in LZ4_stream_t 2018-03-12 14:58:43 -04:00
W. Felix Handte
6d156fea56 Allow Empty Dictionaries 2018-03-12 14:58:43 -04:00
Yann Collet
7173a631db edge case : compress up to end-mflimit (12 bytes)
The LZ4 block format specification
states that the last match must start
at a minimum distance of 12 bytes from the end of the block.

However, out of an abundance of caution,
the reference implementation would actually stop searching matches
at 13 bytes from the end of the block.

This patch fixes this small detail.
The new version is now able to properly compress a limit case
such as `aaaaaaaabaaa\n`
as reported by Gao Xiang (@hsiangkao).

Obviously, it doesn't change a lot of things.
This is just one additional match candidate per block, with a maximum match length of 7 (since last 5 bytes must remain literals).

With default policy, blocks are 4 MB long, so it doesn't happen too often
Compressing silesia.tar at default level 1 saves 5 bytes (100930101 -> 100930096).
At max level 12, it saves a grand 16 bytes (77389871 -> 77389855).

The impact is a bit more visible when blocks are smaller, hence more numerous.
For example, compressing silesia with blocks of 64 KB (using -12 -B4D) saves 543 bytes (77304583 -> 77304040).
So the smaller the packet size, the more visible the impact.

And it happens we have a ton of scenarios with little blocks using LZ4 compression ...

And a useless "hooray" sidenote :
the patch improves the LZ4 compression record of silesia (using -12 -B7D --no-frame-crc) by 16 bytes (77270672 -> 77270656)
and the record on enwik9 by 44 bytes (371680396 -> 371680352) (previously claimed by [smallz4](http://create.stephan-brumme.com/smallz4/) ).
2018-02-24 11:47:53 -08:00
Yann Collet
219abab74b removed LZ4_copy8
better use memcpy() directly
2018-02-11 22:20:09 -08:00
Yann Collet
3ad3b0f850 slightly improved decompression speed (~+1-2%)
by making shortcut slightly more common
2018-02-11 01:43:20 -08:00
Ben Boeckel
c4671be550 intel: do not use __attribute__((packed)) on Windows
On Windows, the Intel compiler is closer to MSVC rather than GCC and
does not support the GCC attribute syntax.

Fixes #468
2018-02-08 09:15:27 -05:00
Yann Collet
6bbe45e1b8 remove register keyword
deprecated in newer C++ versions,
and dubious utility
2017-12-04 17:10:23 -08:00
Yann Collet
dac26084a9
Merge pull request #416 from lz4/newopt
Improve Optimal parser
2017-11-09 14:13:30 -08:00
Yann Collet
9221419c6f added LZ4_FORCEINLINE to counter gcc regression
as recommended by @terrelln
2017-11-06 17:29:27 -08:00
Yann Collet
d51f046628 2-stages LZ4_count
separate first branch from the rest of the compare loop
to get dedicated prediction.

measured a 3-4% compression speed improvement.
2017-11-06 15:42:50 -08:00
Sylvestre Ledru
4fed595dac Only ignore with C++17 2017-11-06 16:16:02 +01:00
Sylvestre Ledru
cca7618f09 When building with a C++ compiler, remove the 'register' keyword to silent a warning
For example, with clang:

lz4.c:XXX:36: error: 'register' storage class specifier is deprecated and incompatible with C++17 [-Werror,-Wdeprecated-register]
static unsigned LZ4_NbCommonBytes (register reg_t val)
                                   ^~~~~~~~~
2017-11-05 11:48:03 +01:00
Yann Collet
8e16eb0cd1 fixed last lost bytes in maximal mode
even gained 2 bytes on calgary.tar...
added conditional traces `g_debuglog_enable`
2017-11-02 14:53:06 -07:00
Yann Collet
15b0d229c1 Merge branch 'dev' into btopt 2017-10-31 17:55:01 -07:00
Yann Collet
a5731d6b26 minor change, to help store forwarding
in a marginal case (offset==4)
2017-10-31 15:51:56 -07:00
Yann Collet
9378f76e41 extended shortcut match length to 18 2017-10-31 14:20:25 -07:00
Yann Collet
ace334a4c9 minor : coding style : use ML_MASK constant 2017-10-31 12:22:15 -07:00
Yann Collet
3f173052ae added comments, as suggested by @terrelln 2017-10-31 11:49:57 -07:00