Improve performance some Integer and Float methods [Feature #19085] (#6638)

* Improve some Integer and Float methods

* Using alias and Remove unnecessary code

* Remove commentout code
This commit is contained in:
S.H 2022-10-28 01:13:16 +09:00 committed by GitHub
parent 7cf7e6c332
commit c6f439a6a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-10-27 16:13:46 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
4 changed files with 81 additions and 79 deletions

View file

@ -2159,31 +2159,6 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
return nucomp_convert(klass, a1, a2, TRUE);
}
/*
* call-seq:
* num.real -> self
*
* Returns self.
*/
static VALUE
numeric_real(VALUE self)
{
return self;
}
/*
* call-seq:
* num.imag -> 0
* num.imaginary -> 0
*
* Returns zero.
*/
static VALUE
numeric_imag(VALUE self)
{
return INT2FIX(0);
}
/*
* call-seq:
* num.abs2 -> real
@ -2255,19 +2230,6 @@ numeric_polar(VALUE self)
return rb_assoc_new(abs, arg);
}
/*
* call-seq:
* num.conj -> self
* num.conjugate -> self
*
* Returns self.
*/
static VALUE
numeric_conj(VALUE self)
{
return self;
}
/*
* call-seq:
* flo.arg -> 0 or float
@ -2433,9 +2395,6 @@ Init_Complex(void)
rb_define_private_method(CLASS_OF(rb_cComplex), "convert", nucomp_s_convert, -1);
rb_define_method(rb_cNumeric, "real", numeric_real, 0);
rb_define_method(rb_cNumeric, "imaginary", numeric_imag, 0);
rb_define_method(rb_cNumeric, "imag", numeric_imag, 0);
rb_define_method(rb_cNumeric, "abs2", numeric_abs2, 0);
rb_define_method(rb_cNumeric, "arg", numeric_arg, 0);
rb_define_method(rb_cNumeric, "angle", numeric_arg, 0);
@ -2443,8 +2402,6 @@ Init_Complex(void)
rb_define_method(rb_cNumeric, "rectangular", numeric_rect, 0);
rb_define_method(rb_cNumeric, "rect", numeric_rect, 0);
rb_define_method(rb_cNumeric, "polar", numeric_polar, 0);
rb_define_method(rb_cNumeric, "conjugate", numeric_conj, 0);
rb_define_method(rb_cNumeric, "conj", numeric_conj, 0);
rb_define_method(rb_cFloat, "arg", float_arg, 0);
rb_define_method(rb_cFloat, "angle", float_arg, 0);