From 51c4ffa45b03262ddc183b815dba07462ef0a29f Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 21 Mar 2016 13:36:03 +0000 Subject: * internal.h (rb_fix_divmod_fix): like r54213, use FIX2NUM only if x == FIXNUM_MIN && y == -1. This must be a rare case and it is expected compiler to handle well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index f95e93c179..d251742bbc 100644 --- a/numeric.c +++ b/numeric.c @@ -3135,7 +3135,7 @@ fix_divide(VALUE x, VALUE y, ID op) { if (FIXNUM_P(y)) { if (FIX2LONG(y) == 0) rb_num_zerodiv(); - return LONG2NUM(rb_div(FIX2LONG(x), FIX2LONG(y))); + return rb_fix_div_fix(x, y); } else if (RB_TYPE_P(y, T_BIGNUM)) { x = rb_int2big(FIX2LONG(x)); @@ -3207,7 +3207,7 @@ fix_mod(VALUE x, VALUE y) { if (FIXNUM_P(y)) { if (FIX2LONG(y) == 0) rb_num_zerodiv(); - return LONG2FIX(rb_mod(FIX2LONG(x), FIX2LONG(y))); + return rb_fix_mod_fix(x, y); } else if (RB_TYPE_P(y, T_BIGNUM)) { x = rb_int2big(FIX2LONG(x)); @@ -3231,10 +3231,10 @@ static VALUE fix_divmod(VALUE x, VALUE y) { if (FIXNUM_P(y)) { - long div, mod; + VALUE div, mod; if (FIX2LONG(y) == 0) rb_num_zerodiv(); - rb_divmod(FIX2LONG(x), FIX2LONG(y), &div, &mod); - return rb_assoc_new(LONG2NUM(div), LONG2FIX(mod)); + rb_fix_divmod_fix(x, y, &div, &mod); + return rb_assoc_new(div, mod); } else if (RB_TYPE_P(y, T_BIGNUM)) { x = rb_int2big(FIX2LONG(x)); -- cgit v1.2.3