static struct symbol * iterator_next_hashed (struct dict_iterator *iterator) { struct symbol *next; next = DICT_ITERATOR_CURRENT (iterator)->hash_next; if (next == NULL) return iterator_hashed_advance (iterator); else { DICT_ITERATOR_CURRENT (iterator) = next; return next; } }
static struct symbol * iter_match_first_hashed (const struct dictionary *dict, const char *name, symbol_compare_ftype *compare, struct dict_iterator *iterator) { unsigned int hash_index = dict_hash (name) % DICT_HASHED_NBUCKETS (dict); struct symbol *sym; DICT_ITERATOR_DICT (iterator) = dict; /* Loop through the symbols in the given bucket, breaking when SYM first matches. If SYM never matches, it will be set to NULL; either way, we have the right return value. */ for (sym = DICT_HASHED_BUCKET (dict, hash_index); sym != NULL; sym = sym->hash_next) { /* Warning: the order of arguments to compare matters! */ if (compare (SYMBOL_SEARCH_NAME (sym), name) == 0) { break; } } DICT_ITERATOR_CURRENT (iterator) = sym; return sym; }
static struct symbol * iter_name_first_hashed (const struct dictionary *dict, const char *name, struct dict_iterator *iterator) { unsigned int hash_index = msymbol_hash_iw (name) % DICT_HASHED_NBUCKETS (dict); struct symbol *sym; DICT_ITERATOR_DICT (iterator) = dict; /* Loop through the symbols in the given bucket, breaking when SYM first matches. If SYM never matches, it will be set to NULL; either way, we have the right return value. */ for (sym = DICT_HASHED_BUCKET (dict, hash_index); sym != NULL; sym = sym->hash_next) { /* Warning: the order of arguments to strcmp_iw matters! */ /* APPLE LOCAL begin psym equivalences */ if ((strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0) || (psym_equivalences && psym_name_match (SYMBOL_SEARCH_NAME (sym), name))) /* APPLE LOCAL end psym equivalences */ { break; } } DICT_ITERATOR_CURRENT (iterator) = sym; return sym; }
static struct symbol * iter_name_next_hashed (const char *name, struct dict_iterator *iterator) { struct symbol *next; for (next = DICT_ITERATOR_CURRENT (iterator)->hash_next; next != NULL; next = next->hash_next) { if (strcmp_iw (SYMBOL_SEARCH_NAME (next), name) == 0) break; } DICT_ITERATOR_CURRENT (iterator) = next; return next; }
static struct symbol * iter_name_next_hashed (const char *name, struct dict_iterator *iterator) { struct symbol *next; for (next = DICT_ITERATOR_CURRENT (iterator)->hash_next; next != NULL; next = next->hash_next) { /* APPLE LOCAL begin psym equivalences */ if ((strcmp_iw (SYMBOL_SEARCH_NAME (next), name) == 0) || (psym_equivalences && psym_name_match (SYMBOL_SEARCH_NAME (next), name))) /* APPLE LOCAL end psym equivalences */ break; } DICT_ITERATOR_CURRENT (iterator) = next; return next; }
static struct symbol * iterator_hashed_advance (struct dict_iterator *iterator) { const struct dictionary *dict = DICT_ITERATOR_DICT (iterator); int nbuckets = DICT_HASHED_NBUCKETS (dict); int i; for (i = DICT_ITERATOR_INDEX (iterator) + 1; i < nbuckets; ++i) { struct symbol *sym = DICT_HASHED_BUCKET (dict, i); if (sym != NULL) { DICT_ITERATOR_INDEX (iterator) = i; DICT_ITERATOR_CURRENT (iterator) = sym; return sym; } } return NULL; }