[vala/staging] codegen: Replace if-else-tree with switch in visit_unary_expression()



commit d41e216e44c24f9761a9a9331e5bc277ce0debeb
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Feb 23 20:19:31 2019 +0100

    codegen: Replace if-else-tree with switch in visit_unary_expression()

 codegen/valaccodebasemodule.vala | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0cb9cf96f..ed583db0b 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5230,19 +5230,26 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                }
 
                CCodeUnaryOperator op;
-               if (expr.operator == UnaryOperator.PLUS) {
+               switch (expr.operator) {
+               case UnaryOperator.PLUS:
                        op = CCodeUnaryOperator.PLUS;
-               } else if (expr.operator == UnaryOperator.MINUS) {
+                       break;
+               case UnaryOperator.MINUS:
                        op = CCodeUnaryOperator.MINUS;
-               } else if (expr.operator == UnaryOperator.LOGICAL_NEGATION) {
+                       break;
+               case UnaryOperator.LOGICAL_NEGATION:
                        op = CCodeUnaryOperator.LOGICAL_NEGATION;
-               } else if (expr.operator == UnaryOperator.BITWISE_COMPLEMENT) {
+                       break;
+               case UnaryOperator.BITWISE_COMPLEMENT:
                        op = CCodeUnaryOperator.BITWISE_COMPLEMENT;
-               } else if (expr.operator == UnaryOperator.INCREMENT) {
+                       break;
+               case UnaryOperator.INCREMENT:
                        op = CCodeUnaryOperator.PREFIX_INCREMENT;
-               } else if (expr.operator == UnaryOperator.DECREMENT) {
+                       break;
+               case UnaryOperator.DECREMENT:
                        op = CCodeUnaryOperator.PREFIX_DECREMENT;
-               } else {
+                       break;
+               default:
                        assert_not_reached ();
                }
                set_cvalue (expr, new CCodeUnaryExpression (op, get_cvalue (expr.inner)));


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