summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2022-09-12 23:57:42 (GMT)
committerYann Collet <cyan@fb.com>2022-09-12 23:57:42 (GMT)
commitf6c18481ceee6586cdee1b4067caa50e20411587 (patch)
tree0e6866f3302119c71f55c263f157330f17050466
parentd91d16b48aa22f179f636123869ea4fbe1d8ccdb (diff)
downloadlz4-f6c18481ceee6586cdee1b4067caa50e20411587.zip
lz4-f6c18481ceee6586cdee1b4067caa50e20411587.tar.gz
lz4-f6c18481ceee6586cdee1b4067caa50e20411587.tar.bz2
simplify getPosition
it's only used in byPtr mode. This removes the need to transfer `base` ptr value.
-rw-r--r--lib/lz4.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 654bfdf..8999137 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -844,20 +844,18 @@ LZ4_FORCE_INLINE U32 LZ4_getIndexOnHash(U32 h, const void* tableBase, tableType_
assert(0); return 0; /* forbidden case */
}
-static const BYTE* LZ4_getPositionOnHash(U32 h, const void* tableBase, tableType_t tableType, const BYTE* srcBase)
+static const BYTE* LZ4_getPositionOnHash(U32 h, const void* tableBase, tableType_t tableType)
{
- if (tableType == byPtr) { const BYTE* const* hashTable = (const BYTE* const*) tableBase; return hashTable[h]; }
- if (tableType == byU32) { const U32* const hashTable = (const U32*) tableBase; return hashTable[h] + srcBase; }
- { const U16* const hashTable = (const U16*) tableBase; return hashTable[h] + srcBase; } /* default, to ensure a return */
+ assert(tableType == byPtr); (void)tableType;
+ { const BYTE* const* hashTable = (const BYTE* const*) tableBase; return hashTable[h]; }
}
LZ4_FORCE_INLINE const BYTE*
LZ4_getPosition(const BYTE* p,
- const void* tableBase, tableType_t tableType,
- const BYTE* srcBase)
+ const void* tableBase, tableType_t tableType)
{
U32 const h = LZ4_hashPosition(p, tableType);
- return LZ4_getPositionOnHash(h, tableBase, tableType, srcBase);
+ return LZ4_getPositionOnHash(h, tableBase, tableType);
}
LZ4_FORCE_INLINE void
@@ -1004,7 +1002,7 @@ LZ4_FORCE_INLINE int LZ4_compress_generic_validated(
if (unlikely(forwardIp > mflimitPlusOne)) goto _last_literals;
assert(ip < mflimitPlusOne);
- match = LZ4_getPositionOnHash(h, cctx->hashTable, tableType, base);
+ match = LZ4_getPositionOnHash(h, cctx->hashTable, tableType);
forwardH = LZ4_hashPosition(forwardIp, tableType);
LZ4_putPositionOnHash(ip, h, cctx->hashTable, tableType, base);
@@ -1209,7 +1207,7 @@ _next_match:
/* Test next position */
if (tableType == byPtr) {
- match = LZ4_getPosition(ip, cctx->hashTable, tableType, base);
+ match = LZ4_getPosition(ip, cctx->hashTable, tableType);
LZ4_putPosition(ip, cctx->hashTable, tableType, base);
if ( (match+LZ4_DISTANCE_MAX >= ip)
&& (LZ4_read32(match) == LZ4_read32(ip)) )