summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-04-13 17:31:42 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-04-13 17:31:42 +0900
commit14514ab40daccb81fbb26ba486a653f9875ff3a6 (patch)
tree3e59bdaf42f7f036dde84785d2a82f22076dc56c
parent12ce2054b09e3f3611ec9bfcc92ec51e9179e2dd (diff)
parent996343caa2281d35324c297ea8867a56da0891ad (diff)
downloadmruby-14514ab40daccb81fbb26ba486a653f9875ff3a6.tar.gz
mruby-14514ab40daccb81fbb26ba486a653f9875ff3a6.zip
Merge branch 'Refactor-numeric.c' of https://github.com/suzukaze/mruby into suzukaze-Refactor-numeric.c
-rw-r--r--src/numeric.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/src/numeric.c b/src/numeric.c
index f7ee3103d..e5fc59ec8 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 */
@@ -1058,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 */