| 630 | |
| 631 | |
| 632 | MEM_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. |
no test coverage detected