diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-08 04:50:22 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-08 04:50:22 +0000 |
commit | b515528271a25e52cdbc28289436c94108141b4a (patch) | |
tree | 154cb627902a55ea3e0238829d79f5c983e74088 /numeric.c | |
parent | 63c7ccc64b6337df88d2395312bf163786ba9056 (diff) |
re-introduce __builtin_add_overflow
r57789 (74cdd89) was gradually "improve"d by naruse through r57793 to
r57806, resulted in reverting the efect of r57789 while retaining its
complexity. I think the current situation is slightly worse than
before (same output complicated source code).
Here I introduce __builtin_add_overflow again, which (I think) is what
naruse wanted to do in r57793.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -3007,16 +3007,15 @@ VALUE rb_num2fix(VALUE val) { long v; - VALUE w; if (FIXNUM_P(val)) { return val; } - else if (rb_long2fix_overflow((v = rb_num2long(val)), &w)) { - rb_raise(rb_eRangeError, "integer %ld out of range of fixnum", v); + else if (rb_long_is_fixable_p(v = rb_num2long(val))) { + return LONG2FIX(v); } else { - return w; + rb_raise(rb_eRangeError, "integer %ld out of range of fixnum", v); } } |