Almost all character strings in SUIF are entered in a hash table called
the lexicon
. This table removes duplicate strings so that string
comparisons can be reduced to simple pointer comparisons. The
lexicon
is an object of the string_table
class defined in
the `stringtable.h' and `stringtable.cc' files.
A string_table
is an open hash table; each bucket is a linked
list of string entries represented by objects of the string_e
class. The only public method in the string_table
class is
called enter
. This method searches the table for a specified
string. If the string is found, enter
returns a pointer to the
existing string_e
entry. Otherwise, it creates a new entry and
adds it to the table. In either case, the actual character string
pointer can be retrieved directly from the sp
field of the
resulting string_e
entry.
None of the strings in the lexicon
are deallocated until a SUIF
program terminates. Consequently, when adding a new string to the
table, it is copied to the heap in case the original string is stored on
the stack. If the string is known to be allocated on the heap and will
never be modified or deallocated, this string copy can be avoided by
setting the optional fixed
flag when calling enter
.