X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=include%2Fwimlib%2Flz_hash.h;h=7416585a979500d9e9259ea2704689bdf2f554e5;hp=5aa4eff5d34319677f1a42e4bca6bf6ff132fd6d;hb=eb3e3b72db23ecaa7789a807afeb9577962653fe;hpb=e7a3df0a6bf2af6500611f6c464dc36cab3332d8 diff --git a/include/wimlib/lz_hash.h b/include/wimlib/lz_hash.h index 5aa4eff5..7416585a 100644 --- a/include/wimlib/lz_hash.h +++ b/include/wimlib/lz_hash.h @@ -1,19 +1,27 @@ /* - * lz_hash.h + * lz_hash.h - hashing for Lempel-Ziv matchfinding * - * Hashing for Lempel-Ziv matchfinding. + * The following copying information applies to this specific source code file: * - * Author: Eric Biggers - * Year: 2014, 2015 + * Written in 2014-2015 by Eric Biggers * - * The author dedicates this file to the public domain. - * You can do whatever you want with this file. + * To the extent possible under law, the author(s) have dedicated all copyright + * and related and neighboring rights to this software to the public domain + * worldwide via the Creative Commons Zero 1.0 Universal Public Domain + * Dedication (the "CC0"). + * + * This software is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the CC0 for more details. + * + * You should have received a copy of the CC0 along with this software; if not + * see . */ #ifndef _LZ_HASH_H #define _LZ_HASH_H -#include "wimlib/unaligned.h" +#include "wimlib/types.h" /* * The hash function: given a sequence prefix held in the low-order bits of a @@ -28,33 +36,4 @@ lz_hash(u32 seq, unsigned num_bits) return (u32)(seq * 0x1E35A7BD) >> (32 - num_bits); } -/* - * Hash the 2-byte sequence beginning at @p, producing a hash of length - * @num_bits bits. At least 2 bytes of data must be available at @p. - */ -static inline u32 -lz_hash_2_bytes(const u8 *p, unsigned num_bits) -{ - u32 seq = load_u16_unaligned(p); - if (num_bits >= 16) - return seq; - return lz_hash(seq, num_bits); -} - -/* - * Hash the 3-byte sequence beginning at @p, producing a hash of length - * @num_bits bits. At least LZ_HASH3_REQUIRED_NBYTES bytes of data must be - * available at @p; note that this may be more than 3. - */ -static inline u32 -lz_hash_3_bytes(const u8 *p, unsigned num_bits) -{ - u32 seq = load_u24_unaligned(p); - if (num_bits >= 24) - return seq; - return lz_hash(seq, num_bits); -} - -#define LZ_HASH3_REQUIRED_NBYTES LOAD_U24_REQUIRED_NBYTES - #endif /* _LZ_HASH_H */