[vala/staging] vala: Replace if-else-tree with switch



commit 7082e4f5312515b612706c68439e948e5927e3be
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Jan 7 11:25:03 2018 +0100

    vala: Replace if-else-tree with switch

 vala/valaassignment.vala |   31 +++++++++++--------------------
 1 files changed, 11 insertions(+), 20 deletions(-)
---
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 6f9f07b..ffeffe7 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -241,26 +241,17 @@ public class Vala.Assignment : Expression {
                                right.target_type = right.target_type.copy ();
                                right.target_type.value_owned = false;
 
-                               if (operator == AssignmentOperator.BITWISE_OR) {
-                                       bin.operator = BinaryOperator.BITWISE_OR;
-                               } else if (operator == AssignmentOperator.BITWISE_AND) {
-                                       bin.operator = BinaryOperator.BITWISE_AND;
-                               } else if (operator == AssignmentOperator.BITWISE_XOR) {
-                                       bin.operator = BinaryOperator.BITWISE_XOR;
-                               } else if (operator == AssignmentOperator.ADD) {
-                                       bin.operator = BinaryOperator.PLUS;
-                               } else if (operator == AssignmentOperator.SUB) {
-                                       bin.operator = BinaryOperator.MINUS;
-                               } else if (operator == AssignmentOperator.MUL) {
-                                       bin.operator = BinaryOperator.MUL;
-                               } else if (operator == AssignmentOperator.DIV) {
-                                       bin.operator = BinaryOperator.DIV;
-                               } else if (operator == AssignmentOperator.PERCENT) {
-                                       bin.operator = BinaryOperator.MOD;
-                               } else if (operator == AssignmentOperator.SHIFT_LEFT) {
-                                       bin.operator = BinaryOperator.SHIFT_LEFT;
-                               } else if (operator == AssignmentOperator.SHIFT_RIGHT) {
-                                       bin.operator = BinaryOperator.SHIFT_RIGHT;
+                               switch (operator) {
+                               case AssignmentOperator.BITWISE_OR: bin.operator = BinaryOperator.BITWISE_OR; 
break;
+                               case AssignmentOperator.BITWISE_AND: bin.operator = 
BinaryOperator.BITWISE_AND; break;
+                               case AssignmentOperator.BITWISE_XOR: bin.operator = 
BinaryOperator.BITWISE_XOR; break;
+                               case AssignmentOperator.ADD: bin.operator = BinaryOperator.PLUS; break;
+                               case AssignmentOperator.SUB: bin.operator = BinaryOperator.MINUS; break;
+                               case AssignmentOperator.MUL: bin.operator = BinaryOperator.MUL; break;
+                               case AssignmentOperator.DIV: bin.operator = BinaryOperator.DIV; break;
+                               case AssignmentOperator.PERCENT: bin.operator = BinaryOperator.MOD; break;
+                               case AssignmentOperator.SHIFT_LEFT: bin.operator = BinaryOperator.SHIFT_LEFT; 
break;
+                               case AssignmentOperator.SHIFT_RIGHT: bin.operator = 
BinaryOperator.SHIFT_RIGHT; break;
                                }
 
                                right = bin;


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