projects
/
selector.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c12e106
)
Cosmetics.
author
Francois Fleuret
<francois@fleuret.org>
Wed, 1 Dec 2010 07:17:41 +0000
(08:17 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Wed, 1 Dec 2010 07:17:41 +0000
(08:17 +0100)
selector.c
patch
|
blob
|
history
diff --git
a/selector.c
b/selector.c
index
d4ddb27
..
eb8e22f
100644
(file)
--- a/
selector.c
+++ b/
selector.c
@@
-214,6
+214,8
@@
void usage(FILE *out) {
/* A quick and dirty hash table */
/* A quick and dirty hash table */
+#define MAGIC_HASH_MULTIPLIER 387433
+
/* The table itself stores indexes of the strings taken in a char**
table. When a string is added, if it was already in the table, the
new index replaces the previous one. */
/* The table itself stores indexes of the strings taken in a char**
table. When a string is added, if it was already in the table, the
new index replaces the previous one. */
@@
-256,11
+258,11
@@
int add_and_get_previous_index(struct hash_table_t *hash_table,
int k;
/* This is my recipe. I checked, it seems to work (as long as
int k;
/* This is my recipe. I checked, it seems to work (as long as
- hash_table->size is not a multiple of
387433 that should be
- okay) */
+ hash_table->size is not a multiple of
MAGIC_HASH_MULTIPLIER that
+
should be
okay) */
for(k = 0; new_string[k]; k++) {
for(k = 0; new_string[k]; k++) {
- code = code *
387433
+ (unsigned int) (new_string[k]);
+ code = code *
MAGIC_HASH_MULTIPLIER
+ (unsigned int) (new_string[k]);
}
code = code % hash_table->size;
}
code = code % hash_table->size;