summaryrefslogtreecommitdiff
path: root/ccode
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2017-12-05 20:19:28 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2017-12-05 20:25:22 +0100
commit1a90e25090d9623455f269ba8db4422c29747adc (patch)
tree579fa049c17c0fbef783effef62891fd3395cef4 /ccode
parent6a25ffbf1b859c8960aa0211cd58e0878007a29f (diff)
downloadvala-1a90e25090d9623455f269ba8db4422c29747adc.tar.gz
ccode: Replace if-else-tree with switch
Diffstat (limited to 'ccode')
-rw-r--r--ccode/valaccodeassignment.vala37
1 files changed, 13 insertions, 24 deletions
diff --git a/ccode/valaccodeassignment.vala b/ccode/valaccodeassignment.vala
index 37b48f33c..57f525d1b 100644
--- a/ccode/valaccodeassignment.vala
+++ b/ccode/valaccodeassignment.vala
@@ -50,31 +50,20 @@ public class Vala.CCodeAssignment : CCodeExpression {
public override void write (CCodeWriter writer) {
left.write (writer);
- writer.write_string (" ");
-
- if (operator == CCodeAssignmentOperator.BITWISE_OR) {
- writer.write_string ("|");
- } else if (operator == CCodeAssignmentOperator.BITWISE_AND) {
- writer.write_string ("&");
- } else if (operator == CCodeAssignmentOperator.BITWISE_XOR) {
- writer.write_string ("^");
- } else if (operator == CCodeAssignmentOperator.ADD) {
- writer.write_string ("+");
- } else if (operator == CCodeAssignmentOperator.SUB) {
- writer.write_string ("-");
- } else if (operator == CCodeAssignmentOperator.MUL) {
- writer.write_string ("*");
- } else if (operator == CCodeAssignmentOperator.DIV) {
- writer.write_string ("/");
- } else if (operator == CCodeAssignmentOperator.PERCENT) {
- writer.write_string ("%");
- } else if (operator == CCodeAssignmentOperator.SHIFT_LEFT) {
- writer.write_string ("<<");
- } else if (operator == CCodeAssignmentOperator.SHIFT_RIGHT) {
- writer.write_string (">>");
+ switch (operator) {
+ case CCodeAssignmentOperator.SIMPLE: writer.write_string (" = "); break;
+ case CCodeAssignmentOperator.BITWISE_OR: writer.write_string (" |= "); break;
+ case CCodeAssignmentOperator.BITWISE_AND: writer.write_string (" &= "); break;
+ case CCodeAssignmentOperator.BITWISE_XOR: writer.write_string (" ^= "); break;
+ case CCodeAssignmentOperator.ADD: writer.write_string (" += "); break;
+ case CCodeAssignmentOperator.SUB: writer.write_string (" -= "); break;
+ case CCodeAssignmentOperator.MUL: writer.write_string (" *= "); break;
+ case CCodeAssignmentOperator.DIV: writer.write_string (" /= "); break;
+ case CCodeAssignmentOperator.PERCENT: writer.write_string (" %= "); break;
+ case CCodeAssignmentOperator.SHIFT_LEFT: writer.write_string (" <<= "); break;
+ case CCodeAssignmentOperator.SHIFT_RIGHT: writer.write_string (" >>= "); break;
+ default: assert_not_reached ();
}
-
- writer.write_string ("= ");
right.write (writer);
}