1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

complex.c: replace misused UNLIKELY with LIKELY

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mrkn 2019-01-08 04:53:06 +00:00
parent 1e87935958
commit bbd1e83e5a

View file

@ -72,7 +72,7 @@ inline static VALUE
f_add(VALUE x, VALUE y) f_add(VALUE x, VALUE y)
{ {
if (RB_INTEGER_TYPE_P(x) && if (RB_INTEGER_TYPE_P(x) &&
UNLIKELY(rb_method_basic_definition_p(rb_cInteger, idPLUS))) { LIKELY(rb_method_basic_definition_p(rb_cInteger, idPLUS))) {
if (FIXNUM_ZERO_P(x)) if (FIXNUM_ZERO_P(x))
return y; return y;
if (FIXNUM_ZERO_P(y)) if (FIXNUM_ZERO_P(y))
@ -80,13 +80,13 @@ f_add(VALUE x, VALUE y)
return rb_int_plus(x, y); return rb_int_plus(x, y);
} }
else if (RB_FLOAT_TYPE_P(x) && else if (RB_FLOAT_TYPE_P(x) &&
UNLIKELY(rb_method_basic_definition_p(rb_cFloat, idPLUS))) { LIKELY(rb_method_basic_definition_p(rb_cFloat, idPLUS))) {
if (FIXNUM_ZERO_P(y)) if (FIXNUM_ZERO_P(y))
return x; return x;
return rb_float_plus(x, y); return rb_float_plus(x, y);
} }
else if (RB_TYPE_P(x, T_RATIONAL) && else if (RB_TYPE_P(x, T_RATIONAL) &&
UNLIKELY(rb_method_basic_definition_p(rb_cRational, idPLUS))) { LIKELY(rb_method_basic_definition_p(rb_cRational, idPLUS))) {
if (FIXNUM_ZERO_P(y)) if (FIXNUM_ZERO_P(y))
return x; return x;
return rb_rational_plus(x, y); return rb_rational_plus(x, y);
@ -124,7 +124,7 @@ inline static VALUE
f_mul(VALUE x, VALUE y) f_mul(VALUE x, VALUE y)
{ {
if (RB_INTEGER_TYPE_P(x) && if (RB_INTEGER_TYPE_P(x) &&
UNLIKELY(rb_method_basic_definition_p(rb_cInteger, idMULT))) { LIKELY(rb_method_basic_definition_p(rb_cInteger, idMULT))) {
if (FIXNUM_ZERO_P(y)) if (FIXNUM_ZERO_P(y))
return ZERO; return ZERO;
if (FIXNUM_ZERO_P(x) && RB_INTEGER_TYPE_P(y)) if (FIXNUM_ZERO_P(x) && RB_INTEGER_TYPE_P(y))
@ -134,16 +134,16 @@ f_mul(VALUE x, VALUE y)
return rb_int_mul(x, y); return rb_int_mul(x, y);
} }
else if (RB_FLOAT_TYPE_P(x) && else if (RB_FLOAT_TYPE_P(x) &&
UNLIKELY(rb_method_basic_definition_p(rb_cFloat, idMULT))) { LIKELY(rb_method_basic_definition_p(rb_cFloat, idMULT))) {
if (y == ONE) return x; if (y == ONE) return x;
return rb_float_mul(x, y); return rb_float_mul(x, y);
} }
else if (RB_TYPE_P(x, T_RATIONAL) && else if (RB_TYPE_P(x, T_RATIONAL) &&
UNLIKELY(rb_method_basic_definition_p(rb_cRational, idMULT))) { LIKELY(rb_method_basic_definition_p(rb_cRational, idMULT))) {
if (y == ONE) return x; if (y == ONE) return x;
return rb_rational_mul(x, y); return rb_rational_mul(x, y);
} }
else if (UNLIKELY(rb_method_basic_definition_p(CLASS_OF(x), idMULT))) { else if (LIKELY(rb_method_basic_definition_p(CLASS_OF(x), idMULT))) {
if (y == ONE) return x; if (y == ONE) return x;
} }
return rb_funcall(x, '*', 1, y); return rb_funcall(x, '*', 1, y);
@ -153,7 +153,7 @@ inline static VALUE
f_sub(VALUE x, VALUE y) f_sub(VALUE x, VALUE y)
{ {
if (FIXNUM_ZERO_P(y) && if (FIXNUM_ZERO_P(y) &&
UNLIKELY(rb_method_basic_definition_p(CLASS_OF(x), idMINUS))) { LIKELY(rb_method_basic_definition_p(CLASS_OF(x), idMINUS))) {
return x; return x;
} }
return rb_funcall(x, '-', 1, y); return rb_funcall(x, '-', 1, y);