diff options
author | Jim Meyering <jim@meyering.net> | 2007-09-25 21:27:14 +0200 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-09-25 21:27:14 +0200 |
commit | 0359c2e1cad84b1c5008c622afd47cd10db2f55d (patch) | |
tree | 090678be2875b9e3ccb4f8d9c29d0e6c42fb8312 /gl/lib | |
parent | e2a6cbca3ba9f2a198c741a1fec6f27c6cb198d8 (diff) | |
download | coreutils-0359c2e1cad84b1c5008c622afd47cd10db2f55d.tar.xz |
Use XOR, not OR to combine bits.
* gl/lib/hash-triple.c (triple_hash): Use XOR (^), not OR (|), to
combine the bits from hashing the name and those of the inode number.
Add a few comments and remove out-of-context ones.
Diffstat (limited to 'gl/lib')
-rw-r--r-- | gl/lib/hash-triple.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/gl/lib/hash-triple.c b/gl/lib/hash-triple.c index dfe2a592d..74b9de80c 100644 --- a/gl/lib/hash-triple.c +++ b/gl/lib/hash-triple.c @@ -8,27 +8,18 @@ #include "same.h" #include "same-inode.h" -/* Hash an F_triple. */ +/* Hash an F_triple, and *do* consider the file name. */ size_t triple_hash (void const *x, size_t table_size) { struct F_triple const *p = x; - - /* Also take the name into account, so that when moving N hard links to the - same file (all listed on the command line) all into the same directory, - we don't experience any N^2 behavior. */ - /* FIXME-maybe: is it worth the overhead of doing this - just to avoid N^2 in such an unusual case? N would have - to be very large to make the N^2 factor noticable, and - one would probably encounter a limit on the length of - a command line before it became a problem. */ size_t tmp = hash_pjw (p->name, table_size); /* Ignoring the device number here should be fine. */ - return (tmp | p->st_ino) % table_size; + return (tmp ^ p->st_ino) % table_size; } -/* Hash an F_triple. */ +/* Hash an F_triple, without considering the file name. */ size_t triple_hash_no_name (void const *x, size_t table_size) { |