translate(): recognize @@ and @# token patterns to avoid useless get_tok_value() calls

This commit is contained in:
Stefan Frederik 2021-12-07 19:43:57 +01:00
parent 1e2983483f
commit 5503786979
3 changed files with 17 additions and 14 deletions

View File

@ -145,13 +145,13 @@ void trim_wires(void)
doloops = 0;
xctx->prep_hash_wires = 0;
timer(0);
/* timer(0); */
do {
dbg(1, "trim_wires(): start: %g\n", timer(1));
/* dbg(1, "trim_wires(): start: %g\n", timer(1)); */
changed = 0;
doloops++;
hash_wires(); /* end1 and end2 reset to -1 */
dbg(1, "trim_wires(): hash_wires_1: %g\n", timer(1));
/* dbg(1, "trim_wires(): hash_wires_1: %g\n", timer(1)); */
/* break all wires */
for(i=0;i<xctx->wires;i++) {
@ -210,7 +210,7 @@ void trim_wires(void)
}
dbg(2, "trim_wires(): hashloopcnt = %d, wires = %d\n", hashloopcnt, xctx->wires);
}
dbg(1, "trim_wires(): break: %g\n", timer(1));
/* dbg(1, "trim_wires(): break: %g\n", timer(1)); */
/* reduce included wires */
my_realloc(29, &wireflag, xctx->wires*sizeof(unsigned short));
memset(wireflag, 0, xctx->wires*sizeof(unsigned short));
@ -246,7 +246,7 @@ void trim_wires(void)
}
}
}
dbg(1, "trim_wires(): included: %g\n", timer(1));
/* dbg(1, "trim_wires(): included: %g\n", timer(1)); */
/* delete wires */
j = 0;
@ -268,14 +268,14 @@ void trim_wires(void)
xctx->prep_hash_wires=0;
changed = 1;
}
dbg(1, "trim_wires(): delete_1: %g\n", timer(1));
/* dbg(1, "trim_wires(): delete_1: %g\n", timer(1)); */
/* after wire deletions full rehash is needed */
hash_wires();
my_realloc(30, &wireflag, xctx->wires*sizeof(unsigned short));
memset(wireflag, 0, xctx->wires*sizeof(unsigned short));
dbg(1, "trim_wires(): hash_wires_2: %g\n", timer(1));
/* dbg(1, "trim_wires(): hash_wires_2: %g\n", timer(1)); */
/* update endpoint (end1, end2) connection counters */
for(i=0;i<xctx->wires;i++) {
@ -314,7 +314,7 @@ void trim_wires(void)
}
}
}
dbg(1, "trim_wires(): endpoints: %g\n", timer(1));
/* dbg(1, "trim_wires(): endpoints: %g\n", timer(1)); */
/* merge parallel touching (in wire[i].x2, wire[i].y2) wires */
for(i=0;i<xctx->wires;i++) {
@ -341,7 +341,7 @@ void trim_wires(void)
}
}
}
dbg(1, "trim_wires(): merge: %g\n", timer(1));
/* dbg(1, "trim_wires(): merge: %g\n", timer(1)); */
/* delete wires */
j = 0;
@ -364,7 +364,7 @@ void trim_wires(void)
xctx->prep_hash_wires=0; /* after wire deletions full rehash is needed */
changed = 1;
}
dbg(1, "trim_wires(): delete_2: %g\n", timer(1));
/* dbg(1, "trim_wires(): delete_2: %g\n", timer(1)); */
if(changed) {
xctx->need_reb_sel_arr = 1;

View File

@ -2802,9 +2802,12 @@ const char *translate(int inst, const char* s)
{
token[token_pos]='\0';
/* dbg(2, "translate(): token=%s\n", token);*/
/* the @# and @@ patterns are processed later */
if(!strncmp(token, "@#",2) || !strncmp(token, "@@",2)) {
value = NULL;
xctx->get_tok_size = 0;
/* if spiceprefix==0 and token == @spiceprefix then set empty value */
if(!sp_prefix && !strcmp(token, "@spiceprefix")) {
} else if(!sp_prefix && !strcmp(token, "@spiceprefix")) {
value = NULL;
xctx->get_tok_size = 0;
/* not that worth doing this optimization */

View File

@ -214,7 +214,7 @@ unsigned int find_best_color(char colorname[])
double deltar,deltag,deltab;
unsigned int idx;
dbg(1, "find_best_color() start: %g\n", timer(1));
/* dbg(1, "find_best_color() start: %g\n", timer(1)); */
#ifdef __unix__
if( XAllocNamedColor(display, colormap, colorname, &xcolor_exact, &xcolor) ==0 )
#else
@ -258,7 +258,7 @@ unsigned int find_best_color(char colorname[])
idx = xc->pixel;
#endif
}
dbg(1, "find_best_color() return: %g\n", timer(1));
/* dbg(1, "find_best_color() return: %g\n", timer(1)); */
return idx;
}