- struct name_table_entry const *result = NULL;
- const struct name_table_entry *const table = _nc_get_table(termcap);
- struct name_table_entry const *ptr;
-
- for (ptr = table; ptr < table + CAPTABSIZE; ptr++) {
- if (ptr->nte_type == type) {
- if (same_name(ptr->nte_name, string, termcap)) {
- result = ptr;
+ struct name_table_entry const *ptr = NULL;
+ const short *hash_table = _nc_get_hash_table(termcap);
+ int hashvalue = hash_function(string);
+
+ if (hash_table[hashvalue] >= 0) {
+ const struct name_table_entry *const table = _nc_get_table(termcap);
+
+ ptr = table + hash_table[hashvalue];
+ while (ptr->nte_type != type
+ || !same_name(ptr->nte_name, string, termcap)) {
+ if (ptr->nte_link < 0) {
+ ptr = 0;
+ break;