diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-08-10 13:56:18 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-08-10 14:22:43 +0900 |
commit | 98c22c78e40d84678e7bac187236e049e9d8c211 (patch) | |
tree | 361f2e7d8d1d68e51fd8f5541fcd462bb398e320 | |
parent | ffdef3674af921d7ddd550dc492dcdbed97f7ba5 (diff) | |
download | bundler-98c22c78e40d84678e7bac187236e049e9d8c211.tar.gz |
Expanded f_real_p
-rw-r--r-- | complex.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -235,7 +235,25 @@ f_negate(VALUE x) return rb_funcall(x, id_negate, 0); } -fun1(real_p) +static VALUE nucomp_real_p(VALUE self); + +static inline bool +f_real_p(VALUE x) +{ + if (RB_INTEGER_TYPE_P(x)) { + return TRUE; + } + else if (RB_FLOAT_TYPE_P(x)) { + return TRUE; + } + else if (RB_TYPE_P(x, T_RATIONAL)) { + return TRUE; + } + else if (RB_TYPE_P(x, T_COMPLEX)) { + return nucomp_real_p(x); + } + return rb_funcall(x, id_real_p, 0); +} inline static VALUE f_to_i(VALUE x) @@ -244,6 +262,7 @@ f_to_i(VALUE x) return rb_str_to_inum(x, 10, 0); return rb_funcall(x, id_to_i, 0); } + inline static VALUE f_to_f(VALUE x) { @@ -1090,7 +1109,8 @@ nucomp_cmp(VALUE self, VALUE other) if (RB_TYPE_P(other, T_COMPLEX) && nucomp_real_p(other)) { get_dat2(self, other); return rb_funcall(adat->real, idCmp, 1, bdat->real); - } else if (f_real_p(other)) { + } + else if (f_real_p(other)) { get_dat1(self); return rb_funcall(dat->real, idCmp, 1, other); } |