summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--lib/lz4.c8
2 files changed, 7 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index f98f2c7..7bfa3c5 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Added : Debianization, by Evgeniy Polyakov
Makefile: Generates object files (*.o) for faster (re)compilation on low power systems
Fix : cli : crash on some invalid inputs
Fix : cli : -t correctly validates lz4-compressed files, by Nick Terrell
+Fix : better ratio on 64-bits big-endian targets
r131
New : Dos/DJGPP target, thanks to Louis Santillan (#114)
diff --git a/lib/lz4.c b/lib/lz4.c
index 0777d5e..b935b76 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -420,11 +420,15 @@ static U32 LZ4_hashSequence(U32 sequence, tableType_t const tableType)
return ((sequence * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
}
-static const U64 prime5bytes = 889523592379ULL;
static U32 LZ4_hashSequence64(U64 sequence, tableType_t const tableType)
{
+ static const U64 prime5bytes = 889523592379ULL;
+ static const U64 prime8bytes = 11400714785074694791ULL;
const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
- return ((sequence << 24) * prime5bytes) >> (64 - hashLog);
+ if (LZ4_isLittleEndian())
+ return ((sequence << 24) * prime5bytes) >> (64 - hashLog);
+ else
+ return ((sequence >> 24) * prime8bytes) >> (64 - hashLog);
}
static U32 LZ4_hashSequenceT(size_t sequence, tableType_t const tableType)