Ejemplo n.º 1
0
 protected static uint LZ4_hashPosition(void *p, tableType_t tableType)
 {
                 #if !BIT32
     if (tableType != tableType_t.byU16)
     {
         return(LZ4_hash5(Mem.PeekW(p), tableType));
     }
                 #endif
     return(LZ4_hash4(Mem.Peek4(p), tableType));
 }
Ejemplo n.º 2
0
        protected static uint LZ4_count(byte *pIn, byte *pMatch, byte *pInLimit)
        {
            const int STEPSIZE = ALGORITHM_ARCH;

            var pStart = pIn;

            if (pIn < pInLimit - (STEPSIZE - 1))
            {
                var diff = Mem.PeekW(pMatch) ^ Mem.PeekW(pIn);
                if (diff != 0)
                {
                    return(LZ4_NbCommonBytes(diff));
                }

                pIn    += STEPSIZE;
                pMatch += STEPSIZE;
            }

            while (pIn < pInLimit - (STEPSIZE - 1))
            {
                var diff = Mem.PeekW(pMatch) ^ Mem.PeekW(pIn);
                if (diff != 0)
                {
                    return((uint)(pIn + LZ4_NbCommonBytes(diff) - pStart));
                }

                pIn    += STEPSIZE;
                pMatch += STEPSIZE;
            }

                        #if !BIT32
            if (pIn < pInLimit - 3 && Mem.Peek4(pMatch) == Mem.Peek4(pIn))
            {
                pIn    += 4;
                pMatch += 4;
            }
                        #endif

            if (pIn < pInLimit - 1 && Mem.Peek2(pMatch) == Mem.Peek2(pIn))
            {
                pIn    += 2;
                pMatch += 2;
            }

            if (pIn < pInLimit && *pMatch == *pIn)
            {
                pIn++;
            }

            return((uint)(pIn - pStart));
        }