chiark / gitweb /
Add global unihash table; use universal hashing instead of CRC.
[mLib] / sym.c
diff --git a/sym.c b/sym.c
index 3aea8c74e7f28423dbc37040922cfe38bb5811bd..a3c9b864b143bff47dafe5ecce3df4a32d6d135d 100644 (file)
--- a/sym.c
+++ b/sym.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: sym.c,v 1.13 2001/01/25 21:14:49 mdw Exp $
+ * $Id: sym.c,v 1.14 2003/12/15 20:53:47 mdw Exp $
  *
  * Symbol table management
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: sym.c,v $
+ * Revision 1.14  2003/12/15 20:53:47  mdw
+ * Add global unihash table; use universal hashing instead of CRC.
+ *
  * Revision 1.13  2001/01/25 21:14:49  mdw
  * Always add a terminating null, and don't count it in the length.
  *
 #include "alloc.h"
 #include "arena.h"
 #include "bits.h"
-#include "crc32.h"
 #include "exc.h"
 #include "hash.h"
 #include "sub.h"
 #include "sym.h"
+#include "unihash.h"
 
 /*----- Main code ---------------------------------------------------------*/
 
@@ -141,7 +144,7 @@ void sym_destroy(sym_table *t)
 /* --- @sym_find@ --- *
  *
  * Arguments:  @sym_table *t@ = pointer to symbol table in question
- *             @const char *n@ = pointer to symbol table to look up
+ *             @const char *n@ = pointer to symbol name to look up
  *             @long l@ = length of the name string or negative to measure
  *             @size_t sz@ = size of desired symbol object, or zero
  *             @unsigned *f@ = pointer to a flag, or null.
@@ -179,7 +182,7 @@ void *sym_find(sym_table *t, const char *n, long l, size_t sz, unsigned *f)
   /* --- Find the correct bin --- */
 
   len = l < 0 ? strlen(n) : l;
-  CRC32(hash, 0, n, len);
+  hash = UNIHASH(&unihash_global, n, len);
   bin = HASH_BIN(&t->t, hash);
 
   /* --- Search the bin list --- */