9#ifndef BROTLI_ENC_FIND_MATCH_LENGTH_H_
10#define BROTLI_ENC_FIND_MATCH_LENGTH_H_
14#include "../common/platform.h"
16#if defined(__cplusplus) || defined(c_plusplus)
21#if defined(BROTLI_TZCNT64) && BROTLI_64_BITS && BROTLI_LITTLE_ENDIAN
22static BROTLI_INLINE
size_t FindMatchLengthWithLimit(
const uint8_t* s1,
25 const uint8_t *s1_orig = s1;
26 for (; limit >= 8; limit -= 8) {
27 uint64_t x = BROTLI_UNALIGNED_LOAD64LE(s2) ^
28 BROTLI_UNALIGNED_LOAD64LE(s1);
31 size_t matching_bits = (size_t)BROTLI_TZCNT64(x);
32 return (
size_t)(s1 - s1_orig) + (matching_bits >> 3);
36 while (limit && *s1 == *s2) {
41 return (
size_t)(s1 - s1_orig);
44static BROTLI_INLINE
size_t FindMatchLengthWithLimit(
const uint8_t* s1,
48 const uint8_t* s2_limit = s2 + limit;
49 const uint8_t* s2_ptr = s2;
54 while (s2_ptr <= s2_limit - 4 &&
55 BrotliUnalignedRead32(s2_ptr) ==
56 BrotliUnalignedRead32(s1 + matched)) {
60 while ((s2_ptr < s2_limit) && (s1[matched] == *s2_ptr)) {
68#if defined(__cplusplus) || defined(c_plusplus)
Common types used in decoder and encoder API.