From f8e1633c0da09223a5b6dd727dfbcc584e03d74e Mon Sep 17 00:00:00 2001 From: Jun Hiroe Date: Sun, 13 Apr 2014 00:37:55 +0900 Subject: Refactor fix_lshift --- src/numeric.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src/numeric.c') diff --git a/src/numeric.c b/src/numeric.c index f7ee3103d..6998adacd 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -1024,27 +1024,18 @@ fix_shift_get_width(mrb_state *mrb, mrb_int *width) static mrb_value fix_lshift(mrb_state *mrb, mrb_value x) { - mrb_int width; - mrb_value result; + mrb_int width, val; fix_shift_get_width(mrb, &width); if (width == 0) { - result = x; + return(x); } - else { - mrb_int val; - - val = mrb_fixnum(x); - if (width < 0) { - result = rshift(val, -width); - } - else { - result = lshift(mrb, val, width); - } + val = mrb_fixnum(x); + if (width < 0) { + return(rshift(val, -width)); } - - return result; + return(lshift(mrb, val, width)); } /* 15.2.8.3.13 */ -- cgit v1.2.3 From 996343caa2281d35324c297ea8867a56da0891ad Mon Sep 17 00:00:00 2001 From: Jun Hiroe Date: Sun, 13 Apr 2014 00:41:22 +0900 Subject: Refactor fix_rshift --- src/numeric.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src/numeric.c') diff --git a/src/numeric.c b/src/numeric.c index 6998adacd..e5fc59ec8 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -1049,27 +1049,18 @@ fix_lshift(mrb_state *mrb, mrb_value x) static mrb_value fix_rshift(mrb_state *mrb, mrb_value x) { - mrb_int width; - mrb_value result; + mrb_int width, val; fix_shift_get_width(mrb, &width); if (width == 0) { - result = x; + return(x); } - else { - mrb_int val; - - val = mrb_fixnum(x); - if (width < 0) { - result = lshift(mrb, val, -width); - } - else { - result = rshift(val, width); - } + val = mrb_fixnum(x); + if (width < 0) { + return(lshift(mrb, val, -width)); } - - return result; + return(rshift(val, width)); } /* 15.2.8.3.23 */ -- cgit v1.2.3