[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/8] bitset: clean up ebitset.c
From: |
Akim Demaille |
Subject: |
[PATCH 4/8] bitset: clean up ebitset.c |
Date: |
Sat, 27 Oct 2018 19:20:01 +0200 |
* lib/ebitset.c: Reduce scopes, etc.
---
lib/ebitset.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/lib/ebitset.c b/lib/ebitset.c
index dd245ff9..561816b1 100644
--- a/lib/ebitset.c
+++ b/lib/ebitset.c
@@ -22,10 +22,11 @@
#include "ebitset.h"
-#include "obstack.h"
#include <stdlib.h>
#include <string.h>
+#include "obstack.h"
+
/* This file implements expandable bitsets. These bitsets can be of
arbitrary length and are more efficient than arrays of bits for
large sparse sets.
@@ -73,7 +74,7 @@ typedef ebitset_elt *ebitset_elts;
/* Number of elements to initially allocate. */
#ifndef EBITSET_INITIAL_SIZE
-#define EBITSET_INITIAL_SIZE 2
+# define EBITSET_INITIAL_SIZE 2
#endif
@@ -131,8 +132,6 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
if (oldsize < newsize)
{
- bitset_windex size;
-
/* The bitset needs to grow. If we already have enough memory
allocated, then just zero what we need. */
if (newsize > EBITSET_ASIZE (src))
@@ -142,11 +141,7 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
grow the bitset 25% larger than requested to reduce
number of reallocations. */
- if (oldsize == 0)
- size = newsize;
- else
- size = newsize + newsize / 4;
-
+ bitset_windex size = oldsize == 0 ? newsize : newsize + newsize / 4;
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = size;
@@ -274,7 +269,6 @@ ebitset_elt_zero_p (ebitset_elt *elt)
for (int i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (elt)[i])
return false;
-
return true;
}
@@ -378,7 +372,6 @@ ebitset_zero (bitset bset)
for (bitset_windex j = 0; j < EBITSET_SIZE (bset); j++)
{
ebitset_elt *elt = elts[j];
-
if (elt)
ebitset_elt_remove (bset, j);
}
@@ -439,7 +432,6 @@ ebitset_copy_ (bitset dst, bitset src)
for (bitset_windex j = 0; j < EBITSET_SIZE (src); j++)
{
ebitset_elt *selt = selts[j];
-
if (selt)
{
ebitset_elt *tmp = ebitset_elt_alloc ();
--
2.19.1
- [PATCH 0/8] bitset: more clean up, Akim Demaille, 2018/10/27
- [PATCH 8/8] bitset: clean up bbitset.h, Akim Demaille, 2018/10/27
- [PATCH 7/8] bitset: clean up lib/bitset.h, Akim Demaille, 2018/10/27
- [PATCH 4/8] bitset: clean up ebitset.c,
Akim Demaille <=
- [PATCH 1/8] bitset: clean up abitset.c, Akim Demaille, 2018/10/27
- [PATCH 3/8] bitset: clean up bitset_stats.c, Akim Demaille, 2018/10/27
- [PATCH 2/8] bitset: clean up bitset.c, Akim Demaille, 2018/10/27
- [PATCH 5/8] bitset: clean up lbitset.c, Akim Demaille, 2018/10/27
- [PATCH 6/8] bitset: clean up vbitset.c, Akim Demaille, 2018/10/27