eliminated duplicated string hash functions
This commit is contained in:
parent
1fa2486e44
commit
52c508423e
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
static unsigned int hi_hash(const char *tok)
|
||||
{
|
||||
register unsigned int hash = 0;
|
||||
register unsigned int hash = 14057;
|
||||
register char *str;
|
||||
register int c;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,17 +22,6 @@
|
|||
|
||||
#include "xschem.h"
|
||||
|
||||
static unsigned int nh_hash(const char *tok)
|
||||
{
|
||||
register unsigned int hash = 0;
|
||||
register int c;
|
||||
|
||||
while ( (c = *tok++) )
|
||||
hash = c + hash * 65599;
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
struct node_hashentry **get_node_table_ptr(void)
|
||||
{
|
||||
return xctx->node_table;
|
||||
|
|
@ -226,7 +215,7 @@ struct node_hashentry *node_hash_lookup(const char *token, const char *dir,int w
|
|||
else if(!strcmp(dir,"out") ) d.out=1;
|
||||
else if(!strcmp(dir,"inout") ) d.inout=1;
|
||||
d.port=port;
|
||||
hashcode=nh_hash(token);
|
||||
hashcode=str_hash(token);
|
||||
index=hashcode % HASHSIZE;
|
||||
entry=xctx->node_table[index];
|
||||
preventry=&xctx->node_table[index];
|
||||
|
|
|
|||
|
|
@ -549,18 +549,6 @@ void spice_netlist(FILE *fd, int spice_stop )
|
|||
if(!spice_stop && !xctx->netlist_count) redraw_hilights(0); /* draw_hilight_net(1); */
|
||||
}
|
||||
|
||||
/* calculate the hash function relative to string s */
|
||||
static unsigned int str_hash(const char *tok)
|
||||
{
|
||||
unsigned int hash = 0;
|
||||
int c;
|
||||
|
||||
while ( (c = *tok++) )
|
||||
hash = c + (hash << 6) + (hash << 16) - hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
/* GENERIC PURPOSE HASH TABLE */
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,9 @@ static struct inst_hashentry *table[HASHSIZE];
|
|||
|
||||
enum status {TOK_BEGIN, TOK_TOKEN, TOK_SEP, TOK_VALUE, TOK_END, TOK_ENDTOK};
|
||||
|
||||
/* calculate the hash function relative to string s */
|
||||
static unsigned int hash(char *tok)
|
||||
unsigned int str_hash(const char *tok)
|
||||
{
|
||||
register unsigned int hash = 0;
|
||||
register unsigned int hash = 14057;
|
||||
register int c;
|
||||
|
||||
while ( (c = *tok++) )
|
||||
|
|
@ -84,7 +83,7 @@ static struct inst_hashentry *inst_hash_lookup(struct inst_hashentry **table, ch
|
|||
int s;
|
||||
|
||||
if(token==NULL) return NULL;
|
||||
hashcode=hash(token);
|
||||
hashcode=str_hash(token);
|
||||
idx=hashcode % HASHSIZE;
|
||||
entry=table[idx];
|
||||
preventry=&table[idx];
|
||||
|
|
|
|||
|
|
@ -1058,6 +1058,7 @@ extern void check_unique_names(int rename);
|
|||
|
||||
extern void clear_instance_hash();
|
||||
|
||||
extern unsigned int str_hash(const char *tok);
|
||||
extern void free_hash(struct hashentry **table);
|
||||
extern struct hashentry *str_hash_lookup(struct hashentry **table, const char *token, const char *value, int what);
|
||||
extern void free_int_hash(struct int_hashentry **table);
|
||||
|
|
|
|||
Loading…
Reference in New Issue