mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rational.c: optimize rational + float.
* rational.c (rb_rational_plus): optimize rational + float. Author: Tadashi Saito <tad.a.digger@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
54bc0a446d
commit
70f5ad7c41
1 changed files with 2 additions and 1 deletions
|
@ -715,6 +715,7 @@ f_addsub(VALUE self, VALUE anum, VALUE aden, VALUE bnum, VALUE bden, int k)
|
|||
return f_rational_new_no_reduce2(CLASS_OF(self), num, den);
|
||||
}
|
||||
|
||||
static VALUE nurat_to_f(VALUE self);
|
||||
/*
|
||||
* call-seq:
|
||||
* rat + numeric -> numeric
|
||||
|
@ -740,7 +741,7 @@ rb_rational_plus(VALUE self, VALUE other)
|
|||
}
|
||||
}
|
||||
else if (RB_TYPE_P(other, T_FLOAT)) {
|
||||
return f_add(f_to_f(self), other);
|
||||
return DBL2NUM(RFLOAT_VALUE(nurat_to_f(self)) + RFLOAT_VALUE(other));
|
||||
}
|
||||
else if (RB_TYPE_P(other, T_RATIONAL)) {
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue