bison-patches
[Top][All Lists]
Advanced

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

[PATCH 2/3] style: reduce: introduce and use a swap for bitset


From: Akim Demaille
Subject: [PATCH 2/3] style: reduce: introduce and use a swap for bitset
Date: Wed, 14 Jan 2015 10:52:20 +0100

* src/reduce.c (bitset_swap): New.
Use it.
---
 src/reduce.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/reduce.c b/src/reduce.c
index 956f68a..50bd55c 100644
--- a/src/reduce.c
+++ b/src/reduce.c
@@ -57,6 +57,13 @@ rule_number nuseless_productions;
 static int nuseful_nonterminals;
 symbol_number nuseless_nonterminals;
 
+#define bitset_swap(Lhs, Rhs)                   \
+  do {                                          \
+    bitset lhs__ = Lhs;                         \
+    Lhs = Rhs;                                  \
+    Rhs = lhs__;                                \
+  } while (0)
+
 /*-------------------------------------------------------------------.
 | Another way to do this would be with a set for each production and |
 | then do subset tests against N0, but even for the C grammar the    |
@@ -119,11 +126,7 @@ useless_nonterminals (void)
           }
       if (bitset_equal_p (N, Np))
         break;
-      {
-        bitset Ns = Np;
-        Np = N;
-        N = Ns;
-      }
+      bitset_swap (N, Np);
     }
   bitset_free (N);
   N = Np;
@@ -181,11 +184,7 @@ inaccessable_symbols (void)
               }
           if (bitset_equal_p (V, Vp))
             break;
-          {
-            bitset Vs = Vp;
-            Vp = V;
-            V = Vs;
-          }
+          bitset_swap (V, Vp);
         }
     }
 
-- 
2.2.1




reply via email to

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