bison-patches
[Top][All Lists]
Advanced

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

[PATCH 06/14] glr2.cc: style: clarify control flow


From: Akim Demaille
Subject: [PATCH 06/14] glr2.cc: style: clarify control flow
Date: Sun, 12 Sep 2021 14:07:39 +0200

* data/skeletons/glr2.cc (yypreference): Be more functional-style.
---
 data/skeletons/glr2.cc | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index b7d33a14..93549639 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -3202,8 +3202,8 @@ namespace ]b4_namespace_ref[
     static int
     yypreference (const semantic_option& y0, const semantic_option& y1)
     {
-      rule_num r0 = y0.yyrule, r1 = y1.yyrule;
-      int p0 = yydprec[r0], p1 = yydprec[r1];
+      const rule_num r0 = y0.yyrule, r1 = y1.yyrule;
+      const int p0 = yydprec[r0], p1 = yydprec[r1];
 
       if (p0 == p1)
         {
@@ -3212,12 +3212,13 @@ namespace ]b4_namespace_ref[
           else
             return 1;
         }
-      if (p0 == 0 || p1 == 0)
+      else if (p0 == 0 || p1 == 0)
         return 0;
-      if (p0 < p1)
+      else if (p0 < p1)
         return 3;
-      if (p1 < p0)
+      else if (p1 < p0)
         return 2;
+      else
         return 0;
     }
 
-- 
2.32.0




reply via email to

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