[iagno] Be strict in Player.



commit 2002822c2cdb86fd4721cec5e3e063536ff2e2d3
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Feb 16 14:54:03 2019 +0100

    Be strict in Player.

 src/player.vala | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
---
diff --git a/src/player.vala b/src/player.vala
index 1398cfb..aec0733 100644
--- a/src/player.vala
+++ b/src/player.vala
@@ -28,13 +28,11 @@ private enum Player
     {
         switch (this)
         {
-        case LIGHT:
-            return "L";
-        case DARK:
-            return "D";
-        default:
-            warn_if_fail (this == NONE);
-            return ".";
+            case LIGHT: return "L";
+            case DARK:  return "D";
+            case NONE:  return ".";
+            default:
+                assert_not_reached ();
         }
     }
 
@@ -43,22 +41,18 @@ private enum Player
     {
         switch (c)
         {
-        case 'L':
-            return LIGHT;
-        case 'D':
-            return DARK;
-        case '.':
-            return NONE;
-        default:
-            warn_if_reached ();
-            return NONE;
+            case 'L':   return LIGHT;
+            case 'D':   return DARK;
+            case '.':   return NONE;
+            default:
+                assert_not_reached ();
         }
     }
 
-    internal static Player flip_color (Player p)
+    internal static inline Player flip_color (Player p)
         requires (p != Player.NONE)
     {
-        return p == Player.LIGHT ? Player.DARK : Player.LIGHT;
+        return (p == Player.LIGHT) ? Player.DARK : Player.LIGHT;
     }
 }
 


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