Use hash table for global name lookups (bug 4496, r=fyren).
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
#include "sc.h"
|
||||
#include <sourcemod_version.h>
|
||||
#include "sctracker.h"
|
||||
#include "sp_symhash.h"
|
||||
#define VERSION_STR "3.2.3636"
|
||||
#define VERSION_INT 0x0302
|
||||
|
||||
@@ -208,6 +209,10 @@ int pc_compile(int argc, char *argv[])
|
||||
if ((jmpcode=setjmp(errbuf))!=0)
|
||||
goto cleanup;
|
||||
|
||||
sp_Globals = NewHashTable();
|
||||
if (!sp_Globals)
|
||||
error(123);
|
||||
|
||||
/* allocate memory for fixed tables */
|
||||
inpfname=(char*)malloc(_MAX_PATH);
|
||||
if (inpfname==NULL)
|
||||
@@ -511,6 +516,7 @@ cleanup:
|
||||
delete_symbols(&loctab,0,TRUE,TRUE); /* delete local variables if not yet
|
||||
* done (i.e. on a fatal error) */
|
||||
delete_symbols(&glbtab,0,TRUE,TRUE);
|
||||
DestroyHashTable(sp_Globals);
|
||||
delete_consttable(&tagname_tab);
|
||||
delete_consttable(&libname_tab);
|
||||
delete_consttable(&sc_automaton_tab);
|
||||
@@ -3837,8 +3843,10 @@ static int operatoradjust(int opertok,symbol *sym,char *opername,int resulttag)
|
||||
refer_symbol(sym,oldsym->refer[i]);
|
||||
delete_symbol(&glbtab,oldsym);
|
||||
} /* if */
|
||||
RemoveFromHashTable(sp_Globals, sym);
|
||||
strcpy(sym->name,tmpname);
|
||||
sym->hash=namehash(sym->name);/* calculate new hash */
|
||||
sym->hash=NameHash(sym->name);/* calculate new hash */
|
||||
AddToHashTable(sp_Globals, sym);
|
||||
|
||||
/* operators should return a value, except the '~' operator */
|
||||
if (opertok!='~')
|
||||
|
||||
Reference in New Issue
Block a user