find_inst_to_be_redrawn(): avoid unneeded call to int_hash_free() if no show net name option active; inst_hash_lookup(): store only pointers to instnames, avoiding strdups
This commit is contained in:
parent
5b01b0c4f1
commit
d44c733fae
|
|
@ -41,7 +41,7 @@ static unsigned int hi_hash(const char *tok)
|
|||
return hash;
|
||||
}
|
||||
|
||||
static struct hilight_hashentry *hilight_hash_free_entry(struct hilight_hashentry *entry)
|
||||
static void hilight_hash_free_entry(struct hilight_hashentry *entry)
|
||||
{
|
||||
struct hilight_hashentry *tmp;
|
||||
while(entry) {
|
||||
|
|
@ -51,7 +51,6 @@ static struct hilight_hashentry *hilight_hash_free_entry(struct hilight_hashentr
|
|||
my_free(757, &entry);
|
||||
entry = tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void hilight_hash_free(void) /* remove the whole hash table */
|
||||
|
|
@ -61,7 +60,8 @@ static void hilight_hash_free(void) /* remove the whole hash table */
|
|||
dbg(2, "hilight_hash_free(): removing hash table\n");
|
||||
for(i=0;i<HASHSIZE;i++)
|
||||
{
|
||||
xctx->hilight_table[i] = hilight_hash_free_entry( xctx->hilight_table[i] );
|
||||
hilight_hash_free_entry( xctx->hilight_table[i] );
|
||||
xctx->hilight_table[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -494,7 +494,7 @@ void find_inst_to_be_redrawn(int what)
|
|||
if(what & 16) {
|
||||
my_free(1202, &xctx->inst_redraw_table);
|
||||
xctx->inst_redraw_table_size = 0;
|
||||
int_hash_free(xctx->node_redraw_table);
|
||||
if((s_pnetname || xctx->hilight_nets)) int_hash_free(xctx->node_redraw_table);
|
||||
return;
|
||||
}
|
||||
if((s_pnetname || xctx->hilight_nets)) {
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ struct node_hashentry *bus_node_hash_lookup(const char *token, const char *dir,
|
|||
return ptr2;
|
||||
}
|
||||
|
||||
static struct node_hashentry *node_hash_free_entry(struct node_hashentry *entry)
|
||||
static void node_hash_free_entry(struct node_hashentry *entry)
|
||||
{
|
||||
struct node_hashentry *tmp;
|
||||
|
||||
|
|
@ -179,7 +179,6 @@ static struct node_hashentry *node_hash_free_entry(struct node_hashentry *entry)
|
|||
my_free(867, &entry);
|
||||
entry = tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void node_hash_free(void) /* remove the whole hash table */
|
||||
|
|
@ -189,7 +188,8 @@ void node_hash_free(void) /* remove the whole hash table */
|
|||
dbg(2, "node_hash_free(): removing hash table\n");
|
||||
for(i=0;i<HASHSIZE;i++)
|
||||
{
|
||||
xctx->node_table[i] = node_hash_free_entry( xctx->node_table[i] );
|
||||
node_hash_free_entry( xctx->node_table[i] );
|
||||
xctx->node_table[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ struct str_hashentry *str_hash_lookup(struct str_hashentry **table, const char *
|
|||
}
|
||||
}
|
||||
|
||||
static struct str_hashentry *str_hash_free_entry(struct str_hashentry *entry)
|
||||
static void str_hash_free_entry(struct str_hashentry *entry)
|
||||
{
|
||||
struct str_hashentry *tmp;
|
||||
while( entry ) {
|
||||
|
|
@ -625,7 +625,6 @@ static struct str_hashentry *str_hash_free_entry(struct str_hashentry *entry)
|
|||
my_free(958, &entry);
|
||||
entry = tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -635,7 +634,8 @@ void str_hash_free(struct str_hashentry **table)
|
|||
|
||||
for(i=0;i<HASHSIZE;i++)
|
||||
{
|
||||
table[i] = str_hash_free_entry( table[i] );
|
||||
str_hash_free_entry( table[i] );
|
||||
table[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -700,7 +700,7 @@ struct int_hashentry *int_hash_lookup(struct int_hashentry **table, const char *
|
|||
}
|
||||
}
|
||||
|
||||
static struct int_hashentry *int_hash_free_entry(struct int_hashentry *entry)
|
||||
static void int_hash_free_entry(struct int_hashentry *entry)
|
||||
{
|
||||
struct int_hashentry *tmp;
|
||||
while( entry ) {
|
||||
|
|
@ -709,7 +709,6 @@ static struct int_hashentry *int_hash_free_entry(struct int_hashentry *entry)
|
|||
my_free(1172, &entry);
|
||||
entry = tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -719,7 +718,8 @@ void int_hash_free(struct int_hashentry **table)
|
|||
|
||||
for(i=0;i<HASHSIZE;i++)
|
||||
{
|
||||
table[i] = int_hash_free_entry( table[i] );
|
||||
int_hash_free_entry( table[i] );
|
||||
table[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
29
src/token.c
29
src/token.c
|
|
@ -57,9 +57,11 @@ int name_strcmp(char *s, char *d) /* compare strings up to '\0' or'[' */
|
|||
|
||||
/* 20180926 added token_size */
|
||||
/* what:
|
||||
* 0,XINSERT : lookup and insert in hash table (return NULL if token was not found)
|
||||
* if token was found update value
|
||||
3,XINSERT_NOREPLACE : same as XINSERT but do not replace existing value if token found.
|
||||
* 0,XINSERT : lookup token and insert xctx->inst[value].instname in hash table
|
||||
* When inserting token must be set to xctx->inst[value].instname
|
||||
* (return NULL if token was not found). If token was found update value
|
||||
* as the table stores only the pointer to xctx->inst[value].instname
|
||||
* 3,XINSERT_NOREPLACE : same as XINSERT but do not replace existing value if token found.
|
||||
* 1,XDELETE : delete token entry, return NULL
|
||||
* 2,XLOOKUP : lookup only
|
||||
*/
|
||||
|
|
@ -83,8 +85,7 @@ static struct inst_hashentry *inst_hash_lookup(char *token, int value, int what,
|
|||
*preventry=entry;
|
||||
entry->next=NULL;
|
||||
entry->hash=hashcode;
|
||||
entry->token = my_malloc(426, token_size + 1);
|
||||
memcpy(entry->token,token, token_size + 1);
|
||||
entry->token = xctx->inst[value].instname; /* do not strdup, store pointer */
|
||||
entry->value = value;
|
||||
}
|
||||
return NULL; /* token was not in hash */
|
||||
|
|
@ -92,7 +93,6 @@ static struct inst_hashentry *inst_hash_lookup(char *token, int value, int what,
|
|||
if( entry->hash==hashcode && !strcmp(token,entry->token) ) { /* found a matching token */
|
||||
if(what == XDELETE) { /* remove token from the hash table ... */
|
||||
saveptr=entry->next;
|
||||
my_free(968, &entry->token);
|
||||
my_free(969, &entry);
|
||||
*preventry=saveptr;
|
||||
return NULL;
|
||||
|
|
@ -107,28 +107,25 @@ static struct inst_hashentry *inst_hash_lookup(char *token, int value, int what,
|
|||
}
|
||||
}
|
||||
|
||||
static struct inst_hashentry *inst_hash_free_entry(struct inst_hashentry *entry)
|
||||
static void inst_hash_free_entry(struct inst_hashentry *entry)
|
||||
{
|
||||
struct inst_hashentry *tmp;
|
||||
while( entry ) {
|
||||
tmp = entry -> next;
|
||||
my_free(970, &(entry->token));
|
||||
dbg(3, "inst_hash_free_entry(): removing entry %lu\n", (unsigned long)entry);
|
||||
my_free(971, &entry);
|
||||
entry = tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void inst_hash_free(void) /* remove the whole hash table */
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
dbg(1, "inst_hash_free(): removing hash table\n");
|
||||
for(i=0;i<HASHSIZE;i++)
|
||||
{
|
||||
xctx->inst_table[i] = inst_hash_free_entry( xctx->inst_table[i] );
|
||||
}
|
||||
dbg(1, "inst_hash_free(): removing hash table\n");
|
||||
for(i=0;i<HASHSIZE;i++) {
|
||||
inst_hash_free_entry( xctx->inst_table[i] );
|
||||
xctx->inst_table[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void hash_all_names(int n)
|
||||
|
|
|
|||
Loading…
Reference in New Issue