[hackers] [scc] [cc1] Move labels to a different hash table || Roberto E. Vargas Caballero
commit e337843c58d1d5b0e91134c6d3173c97708cb291
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Feb 20 08:43:54 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Feb 20 12:19:29 2017 +0100
[cc1] Move labels to a different hash table
diff --git a/cc1/symbol.c b/cc1/symbol.c
index 1126279..3c5f9b1 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
_AT_@ -11,13 +11,16 @@ static char sccsid[] = "@(#) ./cc1/symbol.c";
#include "cc1.h"
#define NR_SYM_HASH 64
+#define NR_CPP_HASH 32
+#define NR_LBL_HASH 16
unsigned curctx;
static unsigned short counterid;
static Symbol *head, *labels;
static Symbol *htab[NR_SYM_HASH];
-static Symbol *htabcpp[NR_SYM_HASH];
+static Symbol *htabcpp[NR_CPP_HASH];
+static Symbol *htablbl[NR_LBL_HASH];
#ifndef NDEBUG
void
_AT_@ -54,15 +57,27 @@ dumpstab(Symbol **tbl, char *msg)
static Symbol **
hash(char *s, int ns)
{
- unsigned c, h;
+ unsigned c, h, size;
Symbol **tab;
for (h = 0; c = *s; ++s)
h = h*33 ^ c;
- h &= NR_SYM_HASH-1;
- tab = (ns == NS_CPP) ? htabcpp : htab;
- return &tab[h];
+ switch (ns) {
+ case NS_CPP:
+ tab = htabcpp;
+ size = NR_CPP_HASH-1;
+ break;
+ case NS_LABEL:
+ tab = htablbl;
+ size = NR_LBL_HASH-1;
+ break;
+ default:
+ tab = htab;
+ size = NR_SYM_HASH-1;
+ break;
+ }
+ return &tab[h & size];
}
static void
Received on Mon Feb 20 2017 - 15:46:49 CET
This archive was generated by hypermail 2.3.0
: Mon Feb 20 2017 - 15:48:19 CET