summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2017-11-06 23:42:50 (GMT)
committerYann Collet <cyan@fb.com>2017-11-06 23:42:50 (GMT)
commitd51f0466289d9a021291e736b463cf8de7bd60bd (patch)
tree2544ff61b33faa9be17babc0bbd7eaa55c703018
parentce8393e8d7c55e69c73ccff0c37c32f5b0e86b6c (diff)
downloadlz4-d51f0466289d9a021291e736b463cf8de7bd60bd.zip
lz4-d51f0466289d9a021291e736b463cf8de7bd60bd.tar.gz
lz4-d51f0466289d9a021291e736b463cf8de7bd60bd.tar.bz2
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.
-rw-r--r--lib/lz4.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 64a2e82..ff6496c 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -407,7 +407,15 @@ static unsigned LZ4_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* pInLi
{
const BYTE* const pStart = pIn;
- while (likely(pIn<pInLimit-(STEPSIZE-1))) {
+ if (likely(pIn < pInLimit-(STEPSIZE-1))) {
+ reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
+ if (!diff) {
+ pIn+=STEPSIZE; pMatch+=STEPSIZE;
+ } else {
+ return LZ4_NbCommonBytes(diff);
+ } }
+
+ while (likely(pIn < pInLimit-(STEPSIZE-1))) {
reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
pIn += LZ4_NbCommonBytes(diff);