Decrease initial size of symbol cache hash table

Using 2^23 allocates 128MB memory for the hash table. Seems like
a waste of memory, especially for small scripts.

For example, I didn't notice a huge difference in time between 1000
and the old number when compiling most of YSI includes and tests.
Hash tables double in size when they need more space, it's pretty
efficient (at least this implementation does so).
This commit is contained in:
Zeex 2018-01-06 10:13:04 +06:00
parent c4e15a032a
commit 6d65605bb0

View File

@ -906,7 +906,7 @@ static void initglobals(void)
sc_asmfile=FALSE; /* do not create .ASM file */
sc_listing=FALSE; /* do not create .LST file */
skipinput=0; /* number of lines to skip from the first input file */
sc_ctrlchar=CTRL_CHAR;/* the escape character */
sc_ctrlchar=CTRL_CHAR; /* the escape character */
litmax=sDEF_LITMAX; /* current size of the literal table */
errnum=0; /* number of errors */
warnnum=0; /* number of warnings */
@ -920,9 +920,9 @@ static void initglobals(void)
#else
sc_compress=FALSE;
#endif
sc_needsemicolon=FALSE;/* semicolon required to terminate expressions? */
sc_needsemicolon=FALSE; /* semicolon required to terminate expressions? */
sc_dataalign=sizeof(cell);
pc_stksize=sDEF_AMXSTACK;/* default stack size */
pc_stksize=sDEF_AMXSTACK; /* default stack size */
pc_amxlimit=0; /* no limit on size of the abstract machine */
pc_amxram=0; /* no limit on data size of the abstract machine */
sc_tabsize=8; /* assume a TAB is 8 spaces */
@ -937,9 +937,9 @@ static void initglobals(void)
litq=NULL; /* the literal queue */
glbtab.next=NULL; /* clear global variables/constants table */
loctab.next=NULL; /* " local " / " " */
hashmap_init(&symbol_cache_map,hashmap_hash_string,hashmap_compare_string,8388608); /* 2^23 */
tagname_tab.next=NULL;/* tagname table */
libname_tab.next=NULL;/* library table (#pragma library "..." syntax) */
hashmap_init(&symbol_cache_map,hashmap_hash_string,hashmap_compare_string,10000);
tagname_tab.next=NULL; /* tagname table */
libname_tab.next=NULL; /* library table (#pragma library "..." syntax) */
pline[0]='\0'; /* the line read from the input file */
lptr=NULL; /* points to the current position in "pline" */