ruby-changes:61739
From: S.H <ko1@a...>
Date: Wed, 17 Jun 2020 02:14:17 +0900 (JST)
Subject: [ruby-changes:61739] eaf76be087 (master): Remove unused else if statements in int_even_p func (#3220)
https://git.ruby-lang.org/ruby.git/commit/?id=eaf76be087 From eaf76be08720fe11e7faf5c3011d9fe58fe3cec4 Mon Sep 17 00:00:00 2001 From: "S.H" <gamelinks007@g...> Date: Wed, 17 Jun 2020 02:13:54 +0900 Subject: Remove unused else if statements in int_even_p func (#3220) * remove else if & rb_funcall * fix int_even_p impl * fix rb_int_odd_p implementation diff --git a/numeric.c b/numeric.c index 0061f08..990d792 100644 --- a/numeric.c +++ b/numeric.c @@ -3252,14 +3252,12 @@ rb_int_odd_p(VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3252 if (num & 2) { return Qtrue; } + return Qfalse; } - else if (RB_TYPE_P(num, T_BIGNUM)) { + else { + assert(RB_TYPE_P(num, T_BIGNUM)); return rb_big_odd_p(num); } - else if (rb_funcall(num, '%', 1, INT2FIX(2)) != INT2FIX(0)) { - return Qtrue; - } - return Qfalse; } /* @@ -3276,14 +3274,12 @@ int_even_p(VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3274 if ((num & 2) == 0) { return Qtrue; } + return Qfalse; } - else if (RB_TYPE_P(num, T_BIGNUM)) { + else { + assert(RB_TYPE_P(num, T_BIGNUM)); return rb_big_even_p(num); } - else if (rb_funcall(num, '%', 1, INT2FIX(2)) == INT2FIX(0)) { - return Qtrue; - } - return Qfalse; } /* -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/