- fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
- this_state->number, symbol, quotearg_style (escape_quoting_style,
- symbols[symbol]->tag));
-
- /* Add up the target state's active item numbers to get a hash key.
- */
- key = 0;
- for (i = 0; i < core_size; ++i)
- key += core[i];
- key = key % STATE_HASH_SIZE;
- sp = state_hash[key];
-
- if (sp)
- {
- int found = 0;
- while (!found)
- {
- if (sp->nitems == core_size)
- {
- found = 1;
- for (i = 0; i < core_size; ++i)
- if (core[i] != sp->items[i])
- found = 0;
- }
-
- if (!found)
- {
- if (sp->link)
- {
- sp = sp->link;
- }
- else /* bucket exhausted and no match */
- {
- sp = sp->link = new_state (symbol, core_size, core);
- found = 1;
- }
- }
- }
- }
- else /* bucket is empty */
- {
- state_hash[key] = sp = new_state (symbol, core_size, core);
- }
+ fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
+ symbol, symbols[symbol]->tag);
+
+ sp = state_hash_lookup (core_size, core);
+ if (!sp)
+ sp = new_state (symbol, core_size, core);