summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2020-05-30 18:15:31 +0900
committerNobuyoshi Nakada <[email protected]>2020-07-01 22:41:15 +0900
commit53d2bfd540c1c9b1038c0b1150b2f397e54b0322 ()
tree814ce069cda03b4a221387c0ee32fc913176e093 /rational.c
parent29ecce4d72db6efc261ace8f951a922bf6b84166 (diff)
Added a few integer case short-circuits
-rw-r--r--rational.c10
1 files changed, 9 insertions, 1 deletions
@@ -60,6 +60,8 @@ f_add(VALUE x, VALUE y)
return x;
if (FIXNUM_ZERO_P(x))
return y;
return rb_funcall(x, '+', 1, y);
}
@@ -78,6 +80,10 @@ f_lt_p(VALUE x, VALUE y)
{
if (FIXNUM_P(x) && FIXNUM_P(y))
return (SIGNED_VALUE)x < (SIGNED_VALUE)y;
return RTEST(rb_funcall(x, '<', 1, y));
}
@@ -137,11 +143,13 @@ f_to_i(VALUE x)
return rb_funcall(x, id_to_i, 0);
}
-inline static VALUE
f_eqeq_p(VALUE x, VALUE y)
{
if (FIXNUM_P(x) && FIXNUM_P(y))
return x == y;
return (int)rb_equal(x, y);
}