From affa0f845cb0d81e0d4a693766cb5875462b467d Mon Sep 17 00:00:00 2001 From: mrkn Date: Wed, 16 Nov 2016 04:25:35 +0000 Subject: complex.c: optimize Numeric#polar and Numeric#arg * complex.c (numeric_polar): optimize for Integer, Float, and Rational. * complex.c (numeric_arg): directly create the value of pi. * complex.c (f_negative_p): optimize for Integer, Float, and Rational. * rational.c (INT_NEGATIVE_P): move the definition into internal.h. * internal.h (INT_NEGATIVE_P): ditto. * numeric.c (rb_float_abs): rename from flo_abs and export to be used from other source files.. * internal.h (rb_float_abs): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index 959626e28d..e7cb105b7d 100644 --- a/numeric.c +++ b/numeric.c @@ -1678,8 +1678,8 @@ flo_to_f(VALUE num) * */ -static VALUE -flo_abs(VALUE flt) +VALUE +rb_float_abs(VALUE flt) { double val = fabs(RFLOAT_VALUE(flt)); return DBL2NUM(val); @@ -5406,8 +5406,8 @@ Init_Numeric(void) rb_define_method(rb_cFloat, "eql?", flo_eql, 1); rb_define_method(rb_cFloat, "hash", flo_hash, 0); rb_define_method(rb_cFloat, "to_f", flo_to_f, 0); - rb_define_method(rb_cFloat, "abs", flo_abs, 0); - rb_define_method(rb_cFloat, "magnitude", flo_abs, 0); + rb_define_method(rb_cFloat, "abs", rb_float_abs, 0); + rb_define_method(rb_cFloat, "magnitude", rb_float_abs, 0); rb_define_method(rb_cFloat, "zero?", flo_zero_p, 0); rb_define_method(rb_cFloat, "to_i", flo_to_i, 0); -- cgit v1.2.3