projects
/
profile
/
extras
/
intel-gpu-tools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9405225
)
Reduce hash value collision probability in src/main.c
author
Homer Hsing
<homer.xing@intel.com>
Fri, 14 Sep 2012 02:06:39 +0000
(10:06 +0800)
committer
Damien Lespiau
<damien.lespiau@intel.com>
Mon, 4 Mar 2013 15:54:32 +0000
(15:54 +0000)
Original code use "hash_value = *name++", which may produce
hash value collision for word permutations like "abc", "bac" and "cba".
assembler/src/main.c
patch
|
blob
|
history
diff --git
a/assembler/src/main.c
b/assembler/src/main.c
index
30c9018
..
d16d271
100644
(file)
--- a/
assembler/src/main.c
+++ b/
assembler/src/main.c
@@
-78,10
+78,10
@@
static void usage(void)
static int hash(char *name)
{
-
int
ret = 0;
+
unsigned
ret = 0;
while(*name)
-
ret += *name++
;
- return ret
%
HASHSZ;
+
ret = (ret << 1) + (*name++)
;
+ return ret
%
HASHSZ;
}
struct declared_register *find_register(char *name)