Minor weak hashtables fixes.
authorLudovic Courtes <ludovic.courtes@laas.fr>
Sun, 25 Jun 2006 22:42:34 +0000 (22:42 +0000)
committerLudovic Courtès <ludo@gnu.org>
Wed, 10 Sep 2008 18:27:46 +0000 (20:27 +0200)
* libguile/hashtab.c (scm_fixup_weak_alist): Cosmetic change.
  (scm_i_rehash): Call `SCM_HASHTABLE_DECREMENT ()' when a deleted weak
  pair is encountered.
  (scm_internal_hash_fold): Call `SCM_HASHTABLE_DECREMENT ()' instead of
  a complicated `SCM_SET_HASHTABLE_N_ITEMS ()'.

git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-40

libguile/hashtab.c

index 7ce42b2..9671a47 100644 (file)
@@ -109,8 +109,7 @@ scm_fixup_weak_alist (SCM alist, size_t *removed_items)
 
       if (scm_is_pair (pair))
        {
-         if ((SCM_WEAK_PAIR_CAR_DELETED_P (pair))
-             || (SCM_WEAK_PAIR_CDR_DELETED_P (pair)))
+         if (SCM_WEAK_PAIR_DELETED_P (pair))
            {
              /* Remove from ALIST weak pair PAIR whose car/cdr has been
                 nullified by the GC.  */
@@ -275,8 +274,11 @@ scm_i_rehash (SCM table,
          ls = SCM_CDR (ls);
 
          if (SCM_WEAK_PAIR_DELETED_P (handle))
-           /* HANDLE is a nullified weak pair: skip it.  */
-           continue;
+           {
+             /* HANDLE is a nullified weak pair: skip it.  */
+             SCM_HASHTABLE_DECREMENT (table);
+             continue;
+           }
 
          h = hash_fn (SCM_CAR (handle), new_size, closure);
          if (h >= new_size)
@@ -1021,14 +1023,8 @@ scm_internal_hash_fold (SCM (*fn) (), void *closure, SCM init, SCM table)
                    SCM_SIMPLE_VECTOR_SET (buckets, i, SCM_CDR (ls));
 
                  if (SCM_HASHTABLE_P (table))
-                   {
-                     /* Update the item count.  */
-                     unsigned long items = SCM_HASHTABLE_N_ITEMS (table);
-
-                     if (items <= 0)
-                       abort ();
-                     SCM_SET_HASHTABLE_N_ITEMS (table, items - 1);
-                   }
+                   /* Update the item count.  */
+                   SCM_HASHTABLE_DECREMENT (table);
 
                  continue;
                }