bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

style: use hash_xinsert


From: Akim Demaille
Subject: style: use hash_xinsert
Date: Sun, 17 May 2020 12:14:24 +0200

commit 4ab492e87acc3f2ea0f5bbbd820b4a4c26874eac
Author: Akim Demaille <address@hidden>
Date:   Sun May 17 12:00:02 2020 +0200

   style: use hash_xinsert

   * gnulib: Update to get hash_xinsert.
   Use it where appropriate.

diff --git a/gnulib b/gnulib
index c8b9cf33..6f3f3992 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit c8b9cf33a910123a1248cdecc4e7776227d4d3dc
+Subproject commit 6f3f39926b3de346695e6213b9378c643dc47817
diff --git a/src/counterexample.c b/src/counterexample.c
index dffca1f8..d1a9ef5b 100644
--- a/src/counterexample.c
+++ b/src/counterexample.c
@@ -680,8 +680,7 @@ ssb_append (search_state *ss)
      search_state_free (ss);
      return;
    }
-  if (!hash_insert (visited, ss))
-    xalloc_die ();
+  hash_xinsert (visited, ss);
  // if states are only referenced by the visited set,
  // their contents should be freed as we only need
  // the metadata necessary to compute a hash.
diff --git a/src/lssi.c b/src/lssi.c
index abf41122..9a925311 100644
--- a/src/lssi.c
+++ b/src/lssi.c
@@ -91,8 +91,7 @@ append_lssi (lssi *sn, Hash_table *visited, gl_list_t queue)
      lssi_free (sn);
      return false;
    }
-  if (!hash_insert (visited, sn))
-    xalloc_die ();
+  hash_xinsert (visited, sn);
  gl_list_add_last (queue, sn);
  return true;
}
diff --git a/src/muscle-tab.c b/src/muscle-tab.c
index 21443f4f..d6d56f32 100644
--- a/src/muscle-tab.c
+++ b/src/muscle-tab.c
@@ -107,8 +107,7 @@ muscle_entry_new (char const *key)
  res->key = key;
  res->value = NULL;
  res->storage = NULL;
-  if (!hash_insert (muscle_table, res))
-    xalloc_die ();
+  hash_xinsert (muscle_table, res);
  return res;
}

diff --git a/src/state-item.c b/src/state-item.c
index 8def146b..82496956 100644
--- a/src/state-item.c
+++ b/src/state-item.c
@@ -82,8 +82,7 @@ hash_pair_insert (Hash_table *tab, int key, bitset val)
  hash_pair *hp = xmalloc (sizeof (hash_pair));
  hp->key = key;
  hp->l = val;
-  if (!hash_insert (tab, hp))
-    xalloc_die ();
+  hash_xinsert (tab, hp);
}

static void
@@ -211,8 +210,7 @@ init_trans (void)
                           (Hash_comparator) state_sym_comparator, NULL);
      for (int j = 0; j < t->num; ++j)
        if (!TRANSITION_IS_DISABLED (t, j))
-          if (!hash_insert (transition_set, t->states[j]))
-            xalloc_die ();
+          hash_xinsert (transition_set, t->states[j]);
      for (int j = state_item_map[i]; j < state_item_map[i + 1]; ++j)
        {
          item_number *item = state_items[j].item;
@@ -298,11 +296,10 @@ init_prods (void)
              hash_pair *prod_hp = xmalloc (sizeof (hash_pair));
              prod_hp->key = j;
              prod_hp->l = copy;
-              //update prods
-              if (!hash_insert (si_prods, prod_hp))
-                xalloc_die ();
+              // update prods.
+              hash_xinsert (si_prods, prod_hp);

-              //update revs
+              // update revs.
              bitset_iterator biter;
              state_item_number prod;
              BITSET_FOR_EACH (biter, copy, prod, 0)
diff --git a/src/state.c b/src/state.c
index 356ccdf1..6118445a 100644
--- a/src/state.c
+++ b/src/state.c
@@ -385,8 +385,7 @@ state_hash_free (void)
void
state_hash_insert (state *s)
{
-  if (!hash_insert (state_table, s))
-    xalloc_die ();
+  hash_xinsert (state_table, s);
}


diff --git a/src/symtab.c b/src/symtab.c
index c9ac27f4..f2421968 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -887,17 +887,16 @@ symbol_from_uniqstr (const uniqstr key, location loc)
  symbol probe;

  probe.tag = key;
-  symbol *entry = hash_lookup (symbol_table, &probe);
+  symbol *res = hash_lookup (symbol_table, &probe);

-  if (!entry)
+  if (!res)
    {
      /* First insertion in the hash. */
      aver (!symbols_sorted);
-      entry = symbol_new (key, loc);
-      if (!hash_insert (symbol_table, entry))
-        xalloc_die ();
+      res = symbol_new (key, loc);
+      hash_xinsert (symbol_table, res);
    }
-  return entry;
+  return res;
}


@@ -912,16 +911,15 @@ semantic_type_from_uniqstr (const uniqstr key, const 
location *loc)
  semantic_type probe;

  probe.tag = key;
-  semantic_type *entry = hash_lookup (semantic_type_table, &probe);
+  semantic_type *res = hash_lookup (semantic_type_table, &probe);

-  if (!entry)
+  if (!res)
    {
      /* First insertion in the hash. */
-      entry = semantic_type_new (key, loc);
-      if (!hash_insert (semantic_type_table, entry))
-        xalloc_die ();
+      res = semantic_type_new (key, loc);
+      hash_xinsert (semantic_type_table, res);
    }
-  return entry;
+  return res;
}


diff --git a/src/uniqstr.c b/src/uniqstr.c
index 6dba20a6..a2b66cc6 100644
--- a/src/uniqstr.c
+++ b/src/uniqstr.c
@@ -50,8 +50,7 @@ uniqstr_new (char const *str)
    {
      /* First insertion in the hash. */
      res = xstrdup (str);
-      if (!hash_insert (uniqstrs_table, res))
-        xalloc_die ();
+      hash_xinsert (uniqstrs_table, res);
    }
  return res;
}
@@ -81,9 +80,7 @@ uniqstr_concat (int nargs, ...)
  va_end (args);

  *p = '\0';
-  uniqstr res = hash_insert (uniqstrs_table, str);
-  if (!res)
-    xalloc_die ();
+  uniqstr res = hash_xinsert (uniqstrs_table, str);
  if (res != str)
    free (str);
  return res;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]