]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Merge remote-tracking branch 'refs/remotes/Cyan4973/dev060' into dev 164/head
authorinikep <inikep@gmail.com>
Thu, 7 Apr 2016 17:50:03 +0000 (19:50 +0200)
committerinikep <inikep@gmail.com>
Thu, 7 Apr 2016 17:50:03 +0000 (19:50 +0200)
# Conflicts:
# lib/zstd_compress.c

1  2 
lib/zstd_compress.c
lib/zstd_opt.h

index 4d737605a1ab7575d984633aa3ab783417c0d003,e6b13ca3e1bf748c719dfda10387787b36365d95..65fea546e4aa8965711b99da238043b516160bf0
@@@ -1508,35 -1695,87 +1513,35 @@@ static size_t ZSTD_BtFindBestMatch_sele
  
  
  
 -/* *******************************
 -*  Greedy parser
 -*********************************/
 -FORCE_INLINE
 -void ZSTD_compressBlock_greedy_generic(ZSTD_CCtx* ctx,
 -                                     const void* src, size_t srcSize)
 -{
 -    seqStore_t* seqStorePtr = &(ctx->seqStore);
 -    const BYTE* const istart = (const BYTE*)src;
 -    const BYTE* ip = istart;
 -    const BYTE* anchor = istart;
 -    const BYTE* const iend = istart + srcSize;
 -    const BYTE* const ilimit = iend - 8;
 -    const BYTE* const base = ctx->base + ctx->dictLimit;
 -
 -    const U32 maxSearches = 1 << ctx->params.cParams.searchLog;
 -    const U32 mls = ctx->params.cParams.searchLength;
 -
 -    /* init */
 -    U32 rep[ZSTD_REP_INIT];
 -    for (U32 i=0; i<ZSTD_REP_INIT; i++)
 -        rep[i]=REPCODE_STARTVALUE;
 -
 -    ZSTD_resetSeqStore(seqStorePtr);
 -    if ((ip-base) < REPCODE_STARTVALUE) ip = base + REPCODE_STARTVALUE;
 -
 -    /* Match Loop */
 -    while (ip < ilimit) {
 -        size_t matchLength=0;
 -        size_t offset=0;
 -        const BYTE* start=ip+1;
 -
 -        /* check repCode */
 -        if (MEM_read32(start) == MEM_read32(start - rep[0])) {
 -            /* repcode : we take it */
 -            matchLength = ZSTD_count(start+EQUAL_READ32, start+EQUAL_READ32-rep[0], iend) + EQUAL_READ32;
 -            goto _storeSequence;
 -        }
 -
 -        /* first search (depth 0) */
 -        {   size_t offsetFound = 99999999;
 -            size_t const ml2 = ZSTD_HcFindBestMatch_selectMLS(ctx, ip, iend, &offsetFound, maxSearches, mls);
 -            if (ml2 > matchLength)
 -                matchLength = ml2, start = ip, offset=offsetFound;
 -        }
--
 -        if (matchLength < EQUAL_READ32) {
 -            ip += ((ip-anchor) >> g_searchStrength) + 1;   /* jump faster over incompressible sections */
 -            continue;
 -        }
 +/* ***********************
 +*  Hash Chain
 +*************************/
  
 -        /* catch up */
 -        while ((start>anchor) && (start>base+offset-ZSTD_REP_MOVE) && (start[-1] == start[-1-offset+ZSTD_REP_MOVE]))   /* only search for offset within prefix */
 -            { start--; matchLength++; }
 -        rep[1] = rep[0]; rep[0] = (U32)(offset - ZSTD_REP_MOVE);
 +#define NEXT_IN_CHAIN(d, mask)   chainTable[(d) & mask]
  
 -_storeSequence:
 -        /* store sequence */
 -        {   size_t const litLength = start - anchor;
 -            ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, matchLength-MINMATCH);
 -            anchor = ip = start + matchLength;
 -        }
 -        /* check immediate repcode */
 -        while ( (ip <= ilimit)
 -             && (MEM_read32(ip) == MEM_read32(ip - rep[1])) ) {
 -            /* store sequence */
 -            matchLength = ZSTD_count(ip+EQUAL_READ32, ip+EQUAL_READ32-rep[1], iend) + EQUAL_READ32;
 -            offset = rep[1]; rep[1] = rep[0]; rep[0] = (U32)offset;  /* swap offset history */
 -            ZSTD_storeSeq(seqStorePtr, 0, anchor, 0, matchLength-MINMATCH);
 -            ip += matchLength;
 -            anchor = ip;
 -            continue;   /* faster when present ... (?) */
 -    }    }
 +/* Update chains up to ip (excluded)
 +   Assumption : always within prefix (ie. not within extDict) */
 +FORCE_INLINE
 +U32 ZSTD_insertAndFindFirstIndex (ZSTD_CCtx* zc, const BYTE* ip, U32 mls)
 +{
 +    U32* const hashTable  = zc->hashTable;
 +    const U32 hashLog = zc->params.cParams.hashLog;
 +    U32* const chainTable = zc->chainTable;
 +    const U32 chainMask = (1 << zc->params.cParams.chainLog) - 1;
 +    const BYTE* const base = zc->base;
 +    const U32 target = (U32)(ip - base);
 +    U32 idx = zc->nextToUpdate;
  
 -    /* Last Literals */
 -    {   size_t const lastLLSize = iend - anchor;
 -        memcpy(seqStorePtr->lit, anchor, lastLLSize);
 -        seqStorePtr->lit += lastLLSize;
 -        ZSTD_statsUpdatePrices(&seqStorePtr->stats, lastLLSize, anchor, 0, 0);
 +    while(idx < target) {
 +        size_t const h = ZSTD_hashPtr(base+idx, hashLog, mls);
 +        NEXT_IN_CHAIN(idx, chainMask) = hashTable[h];
 +        hashTable[h] = idx;
 +        idx++;
      }
 +
 +    zc->nextToUpdate = target;
 +    return hashTable[ZSTD_hashPtr(ip, hashLog, mls)];
  }
  
  
diff --cc lib/zstd_opt.h
Simple merge