MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ZSTD_count

Function ZSTD_count

freebsd/contrib/zstd/lib/compress/zstd_compress_internal.h:632–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630
631
632MEM_STATIC size_t ZSTD_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* const pInLimit)
633{
634 const BYTE* const pStart = pIn;
635 const BYTE* const pInLoopLimit = pInLimit - (sizeof(size_t)-1);
636
637 if (pIn < pInLoopLimit) {
638 { size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
639 if (diff) return ZSTD_NbCommonBytes(diff); }
640 pIn+=sizeof(size_t); pMatch+=sizeof(size_t);
641 while (pIn < pInLoopLimit) {
642 size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
643 if (!diff) { pIn+=sizeof(size_t); pMatch+=sizeof(size_t); continue; }
644 pIn += ZSTD_NbCommonBytes(diff);
645 return (size_t)(pIn - pStart);
646 } }
647 if (MEM_64bits() && (pIn<(pInLimit-3)) && (MEM_read32(pMatch) == MEM_read32(pIn))) { pIn+=4; pMatch+=4; }
648 if ((pIn<(pInLimit-1)) && (MEM_read16(pMatch) == MEM_read16(pIn))) { pIn+=2; pMatch+=2; }
649 if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
650 return (size_t)(pIn - pStart);
651}
652
653/** ZSTD_count_2segments() :
654 * can count match length with `ip` & `match` in 2 different segments.

Calls 5

ZSTD_NbCommonBytesFunction · 0.70
MEM_readSTFunction · 0.50
MEM_64bitsFunction · 0.50
MEM_read32Function · 0.50
MEM_read16Function · 0.50

Tested by

no test coverage detected