Eric Biggers wrote:
> Good news: I tried some different constants for multiplicative hashing, and 
> the
> results for two constants were as good as the CRC-based hash function, and
> faster to compute (at least on x86).  So here's the revised patch that does 
> away
> with static data completely.

Good indeed. Slightly better results than the previous
version.

See comments below.

Jean-Pierre


>
> ---------------
>
> diff --git a/libntfs-3g/compress.c b/libntfs-3g/compress.c
> index 73ad283..b356e35 100644
> --- a/libntfs-3g/compress.c
> +++ b/libntfs-3g/compress.c
[...]

>   
>   /*
> + *           Hash the next 3-byte sequence in the input buffer
> + */
> +static inline unsigned int ntfs_hash(const u8 *p)
> +{
> +     u32 str;
> +
> +#if defined(__i386__) || defined(__x86_64__)
> +     /* Unaligned access okay  */
Also warn about only valid on a little endian cpu.
> +     str = *(u32 *)p & 0xFFFFFF;
Please cast to "const u32*" to avoid a compiler warning
about dropping a const qualifier.
> +#else
> +     str = ((u32)p[0] << 0) | ((u32)p[1] << 8) | ((u32)p[2] << 16);
> +#endif
> +
> +     return (str * HASH_MULTIPLIER) >> (32 - HASH_SHIFT);

This is assuming "int" is 32-bit. Please mask the result
with ((1 << HASH_SHIFT) - 1) for safety.
I have checked that gcc recognizes this as unneeded,
so there is no drop in performance with smart compilers.

[...]

>
> +
> +     /* Search the appropriate hash chain for matches.  */
> +
> +     for (; cur_match >= 0 && depth_remaining--; cur_match = 
> prev[cur_match]) {

Please split this line (and other ones which are not
within the 80 chars limit.)

[...]

------------------------------------------------------------------------------
_______________________________________________
ntfs-3g-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel

Reply via email to