aboutsummaryrefslogtreecommitdiffstats
path: root/complex.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-14 04:06:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-14 04:06:15 +0000
commit9c19130e7f13d96f57ba1b681bf14cc682ee8bce (patch)
tree009aa2f20c9680f9d17e7d66378a5ad294c4742a /complex.c
parent1b63495df2751f2accdf365dcfee7652d8aef656 (diff)
downloadruby-9c19130e7f13d96f57ba1b681bf14cc682ee8bce.tar.gz
complex.c: optimize
* complex.c (f_negative_p): use rb_num_negative_p instead of funcall. * complex.c (f_kind_of_p, f_numeric_p): cast down to int because rb_obj_is_kind_of is safe. * complex.c (f_signbit, f_tpositive_p): remove f_boolcast. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/complex.c b/complex.c
index 998addb460..f6fc6eef19 100644
--- a/complex.c
+++ b/complex.c
@@ -177,12 +177,12 @@ fun2(expt)
fun2(fdiv)
fun2(quo)
-inline static VALUE
+inline static int
f_negative_p(VALUE x)
{
if (FIXNUM_P(x))
- return f_boolcast(FIXNUM_NEGATIVE_P(x));
- return rb_funcall(x, '<', 1, ZERO);
+ return FIXNUM_NEGATIVE_P(x);
+ return rb_num_negative_p(x);
}
#define f_positive_p(x) (!f_negative_p(x))
@@ -202,13 +202,13 @@ f_zero_p(VALUE x)
#define f_nonzero_p(x) (!f_zero_p(x))
-inline static VALUE
+inline static int
f_kind_of_p(VALUE x, VALUE c)
{
- return rb_obj_is_kind_of(x, c);
+ return (int)rb_obj_is_kind_of(x, c);
}
-inline static VALUE
+inline static int
k_numeric_p(VALUE x)
{
return f_kind_of_p(x, rb_cNumeric);
@@ -1209,26 +1209,27 @@ nucomp_eql_p(VALUE self, VALUE other)
return Qfalse;
}
-inline static VALUE
+inline static int
f_signbit(VALUE x)
{
if (RB_FLOAT_TYPE_P(x)) {
double f = RFLOAT_VALUE(x);
- return f_boolcast(!isnan(f) && signbit(f));
+ return !isnan(f) && signbit(f);
}
return f_negative_p(x);
}
-inline static VALUE
+inline static int
f_tpositive_p(VALUE x)
{
- return f_boolcast(!f_signbit(x));
+ return !f_signbit(x);
}
static VALUE
f_format(VALUE self, VALUE (*func)(VALUE))
{
- VALUE s, impos;
+ VALUE s;
+ int impos;
get_dat1(self);