[vala/staging] codegen: Replace if-else-tree with switch
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Replace if-else-tree with switch
- Date: Thu, 22 Nov 2018 14:14:48 +0000 (UTC)
commit 47dbec45949a6e1f68e839578cc5e24da39d627b
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Nov 22 12:36:21 2018 +0100
codegen: Replace if-else-tree with switch
codegen/valaccodeassignmentmodule.vala | 35 +++++++++++++---------------------
1 file changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index c8f24383e..4833e2d1f 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -40,28 +40,19 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
store_value (assignment.left.target_value, assignment.right.target_value,
assignment.source_reference);
} else {
CCodeAssignmentOperator cop;
- if (assignment.operator == AssignmentOperator.BITWISE_OR) {
- cop = CCodeAssignmentOperator.BITWISE_OR;
- } else if (assignment.operator == AssignmentOperator.BITWISE_AND) {
- cop = CCodeAssignmentOperator.BITWISE_AND;
- } else if (assignment.operator == AssignmentOperator.BITWISE_XOR) {
- cop = CCodeAssignmentOperator.BITWISE_XOR;
- } else if (assignment.operator == AssignmentOperator.ADD) {
- cop = CCodeAssignmentOperator.ADD;
- } else if (assignment.operator == AssignmentOperator.SUB) {
- cop = CCodeAssignmentOperator.SUB;
- } else if (assignment.operator == AssignmentOperator.MUL) {
- cop = CCodeAssignmentOperator.MUL;
- } else if (assignment.operator == AssignmentOperator.DIV) {
- cop = CCodeAssignmentOperator.DIV;
- } else if (assignment.operator == AssignmentOperator.PERCENT) {
- cop = CCodeAssignmentOperator.PERCENT;
- } else if (assignment.operator == AssignmentOperator.SHIFT_LEFT) {
- cop = CCodeAssignmentOperator.SHIFT_LEFT;
- } else if (assignment.operator == AssignmentOperator.SHIFT_RIGHT) {
- cop = CCodeAssignmentOperator.SHIFT_RIGHT;
- } else {
- assert_not_reached ();
+
+ switch (assignment.operator) {
+ case AssignmentOperator.BITWISE_OR: cop = CCodeAssignmentOperator.BITWISE_OR; break;
+ case AssignmentOperator.BITWISE_AND: cop = CCodeAssignmentOperator.BITWISE_AND; break;
+ case AssignmentOperator.BITWISE_XOR: cop = CCodeAssignmentOperator.BITWISE_XOR; break;
+ case AssignmentOperator.ADD: cop = CCodeAssignmentOperator.ADD; break;
+ case AssignmentOperator.SUB: cop = CCodeAssignmentOperator.SUB; break;
+ case AssignmentOperator.MUL: cop = CCodeAssignmentOperator.MUL; break;
+ case AssignmentOperator.DIV: cop = CCodeAssignmentOperator.DIV; break;
+ case AssignmentOperator.PERCENT: cop = CCodeAssignmentOperator.PERCENT; break;
+ case AssignmentOperator.SHIFT_LEFT: cop = CCodeAssignmentOperator.SHIFT_LEFT; break;
+ case AssignmentOperator.SHIFT_RIGHT: cop = CCodeAssignmentOperator.SHIFT_RIGHT; break;
+ default: assert_not_reached ();
}
CCodeExpression codenode = new CCodeAssignment (get_cvalue (assignment.left),
get_cvalue (assignment.right), cop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]