]> Savannah Git Hosting - gnulib.git/commitdiff
bitset: minor changes
authorAkim Demaille <akim.demaille@gmail.com>
Tue, 19 Mar 2019 20:26:35 +0000 (21:26 +0100)
committerAkim Demaille <akim.demaille@gmail.com>
Thu, 21 Mar 2019 06:18:17 +0000 (07:18 +0100)
* lib/bitset/base.h (bitset_alloc_type): Remove, unused.
* lib/bitset/table.c: Formatting changes.
Remove useless braces.
Prefer using else in cascades of if/else-if with returns.
* lib/bitset/vector.c: Reduce scopes.

ChangeLog
lib/bitset/base.h
lib/bitset/table.c
lib/bitset/vector.c

index 714610027a6b8bb05791084b1e9c605eb806df6c..88a3a40e11623da0db8e7a8dab3f173c520d6914 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-03-19  Akim Demaille  <akim@lrde.epita.fr>
+
+       bitset: minor changes
+       * lib/bitset/base.h (bitset_alloc_type): Remove, unused.
+       * lib/bitset/table.c: Formatting changes.
+       Remove useless braces.
+       Prefer using else in cascades of if/else-if with returns.
+       * lib/bitset/vector.c: Reduce scopes.
+
 2019-03-19  Akim Demaille  <akim@lrde.epita.fr>
 
        bitset: expose bitset_resize
index 4fcafac8b67d18b8a9d6c885eed4ec27b5e17a5d..fe1b8fbe12952d10fdd291e79f1538ae4bc5665c 100644 (file)
@@ -55,8 +55,6 @@ enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VECTOR,
 
 extern const char * const bitset_type_names[];
 
-enum bitset_alloc_type {BITSET_MALLOC, BITSET_OBALLOC};
-
 /* Data type used to store a word of bits.  */
 typedef unsigned long bitset_word;
 #define BITSET_WORD_BITS ((unsigned) (CHAR_BIT * sizeof (bitset_word)))
index 9cac964694a72db15bd6d5bb892e17f8bcf87736..07184d657480e040e6ac1248c69ee1a27c755746 100644 (file)
@@ -188,21 +188,21 @@ tbitset_elt_alloc (void)
           /* Let particular systems override the size of a chunk.  */
 
 #ifndef OBSTACK_CHUNK_SIZE
-#define OBSTACK_CHUNK_SIZE 0
+# define OBSTACK_CHUNK_SIZE 0
 #endif
 
           /* Let them override the alloc and free routines too.  */
 
 #ifndef OBSTACK_CHUNK_ALLOC
-#define OBSTACK_CHUNK_ALLOC xmalloc
+# define OBSTACK_CHUNK_ALLOC xmalloc
 #endif
 
 #ifndef OBSTACK_CHUNK_FREE
-#define OBSTACK_CHUNK_FREE free
+# define OBSTACK_CHUNK_FREE free
 #endif
 
 #if ! defined __GNUC__ || __GNUC__ < 2
-#define __alignof__(type) 0
+# define __alignof__(type) 0
 #endif
 
           obstack_specify_allocation (&tbitset_obstack, OBSTACK_CHUNK_SIZE,
@@ -1018,13 +1018,9 @@ tbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
         }
 
       if (!tbitset_elt_zero_p (delt))
-        {
-          tbitset_elt_add (dst, delt, j);
-        }
+        tbitset_elt_add (dst, delt, j);
       else
-        {
-          tbitset_elt_free (delt);
-        }
+        tbitset_elt_free (delt);
     }
 
   /* If we have elements of DST left over, free them all.  */
@@ -1059,7 +1055,8 @@ tbitset_and_cmp (bitset dst, bitset src1, bitset src2)
       tbitset_zero (dst);
       return changed;
     }
-  return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
+  else
+    return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_AND);
 }
 
 
@@ -1074,9 +1071,7 @@ static bool
 tbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
 {
   if (EBITSET_ZERO_P (src2))
-    {
-      return tbitset_copy_cmp (dst, src1);
-    }
+    return tbitset_copy_cmp (dst, src1);
   else if (EBITSET_ZERO_P (src1))
     {
       tbitset_weed (dst);
@@ -1084,7 +1079,8 @@ tbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
       tbitset_zero (dst);
       return changed;
     }
-  return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
+  else
+    return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_ANDN);
 }
 
 
@@ -1099,14 +1095,11 @@ static bool
 tbitset_or_cmp (bitset dst, bitset src1, bitset src2)
 {
   if (EBITSET_ZERO_P (src2))
-    {
-      return tbitset_copy_cmp (dst, src1);
-    }
+    return tbitset_copy_cmp (dst, src1);
   else if (EBITSET_ZERO_P (src1))
-    {
-      return tbitset_copy_cmp (dst, src2);
-    }
-  return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
+    return tbitset_copy_cmp (dst, src2);
+  else
+    return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_OR);
 }
 
 
@@ -1121,14 +1114,11 @@ static bool
 tbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
 {
   if (EBITSET_ZERO_P (src2))
-    {
-      return tbitset_copy_cmp (dst, src1);
-    }
+    return tbitset_copy_cmp (dst, src1);
   else if (EBITSET_ZERO_P (src1))
-    {
-      return tbitset_copy_cmp (dst, src2);
-    }
-  return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
+    return tbitset_copy_cmp (dst, src2);
+  else
+    return tbitset_op3_cmp (dst, src1, src2, BITSET_OP_XOR);
 }
 
 
index 15d3e9956775a5dd2b5fe08ad932dd3d2b7470e6..0623651dc443aa19998dc3f9303695b957db1289 100644 (file)
@@ -467,7 +467,6 @@ vbitset_and (bitset dst, bitset src1, bitset src2)
 static bool
 vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
 {
-  bool changed = false;
   vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
 
   bitset_windex dsize = VBITSET_SIZE (dst);
@@ -477,6 +476,7 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
   bitset_word *src1p = VBITSET_WORDS (src1);
   bitset_word *src2p = VBITSET_WORDS (src2);
 
+  bool changed = false;
   unsigned i;
   for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
     {
@@ -546,7 +546,6 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
 static bool
 vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
 {
-  bool changed = false;
   vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
 
   bitset_windex dsize = VBITSET_SIZE (dst);
@@ -556,6 +555,7 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
   bitset_word *src1p = VBITSET_WORDS (src1);
   bitset_word *src2p = VBITSET_WORDS (src2);
 
+  bool changed = false;
   unsigned i;
   for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
     {
@@ -633,8 +633,6 @@ vbitset_or (bitset dst, bitset src1, bitset src2)
 static bool
 vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
 {
-  bool changed = false;
-
   vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
 
   bitset_windex dsize = VBITSET_SIZE (dst);
@@ -644,6 +642,7 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
   bitset_word *src1p = VBITSET_WORDS (src1);
   bitset_word *src2p = VBITSET_WORDS (src2);
 
+  bool changed = false;
   unsigned i;
   for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
     {
@@ -711,7 +710,6 @@ vbitset_xor (bitset dst, bitset src1, bitset src2)
 static bool
 vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
 {
-  bool changed = false;
   vbitset_resize (dst, max (BITSET_SIZE_ (src1), BITSET_SIZE_ (src2)));
 
   bitset_windex dsize = VBITSET_SIZE (dst);
@@ -721,6 +719,7 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
   bitset_word *src1p = VBITSET_WORDS (src1);
   bitset_word *src2p = VBITSET_WORDS (src2);
 
+  bool changed = false;
   unsigned i;
   for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
     {
@@ -903,8 +902,8 @@ vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
   bitset_word *dstp = VBITSET_WORDS (dst);
   bitset_windex size = VBITSET_SIZE (dst);
 
-  unsigned i;
   bool changed = false;
+  unsigned i;
   for (i = 0; i < size; i++, dstp++)
     {
       bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;