mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-02 23:50:47 +02:00
Convert hash tables away from scm_cell
* libguile/hashtab.h (SCM_HASHTABLE_VECTOR): (SCM_SET_HASHTABLE_VECTOR): (SCM_HASHTABLE): (SCM_HASHTABLE_N_ITEMS): (SCM_SET_HASHTABLE_N_ITEMS): (SCM_HASHTABLE_INCREMENT): (SCM_HASHTABLE_DECREMENT): (SCM_HASHTABLE_UPPER): (SCM_HASHTABLE_LOWER): (SCM_HASHTABLE_N_BUCKETS): (SCM_HASHTABLE_BUCKET): (SCM_SET_HASHTABLE_BUCKET): Remove these internal definitions from the public interface. (scm_t_hashtable): Add a tag, and add buckets. (scm_is_hashtable): (scm_to_hashtable): (scm_from_hashtable): New helpers. * libguile/modules.c (scm_module_reverse_lookup): Adapt to hash table API change. * libguile/hashtab.c: Rework to access hash table data through the typed "struct scm_t_hashtable".
This commit is contained in:
parent
b25a743cf9
commit
20fcb8ac12
3 changed files with 158 additions and 99 deletions
|
@ -845,18 +845,18 @@ SCM_DEFINE (scm_module_reverse_lookup, "module-reverse-lookup", 2, 0, 0,
|
|||
/* XXX - We do not use scm_hash_fold here to avoid searching the
|
||||
whole obarray. We should have a scm_hash_find procedure. */
|
||||
|
||||
n = SCM_HASHTABLE_N_BUCKETS (obarray);
|
||||
struct scm_t_hashtable *ht = scm_to_hashtable (obarray);
|
||||
SCM buckets = ht->buckets;
|
||||
n = SCM_SIMPLE_VECTOR_LENGTH (buckets);
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
SCM ls = SCM_HASHTABLE_BUCKET (obarray, i), handle;
|
||||
while (!scm_is_null (ls))
|
||||
for (SCM ls = SCM_SIMPLE_VECTOR_REF (buckets, i);
|
||||
!scm_is_null (ls);
|
||||
ls = SCM_CDR (ls))
|
||||
{
|
||||
handle = SCM_CAR (ls);
|
||||
|
||||
SCM handle = SCM_CAR (ls);
|
||||
if (scm_is_eq (SCM_CDR (handle), variable))
|
||||
return SCM_CAR (handle);
|
||||
|
||||
ls = SCM_CDR (ls);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue