diff options
author | S-H-GAMELINKS <gamelinks007@gmail.com> | 2022-11-15 13:24:08 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-11-16 18:58:33 +0900 |
commit | 1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6 (patch) | |
tree | 823f1ca5409fdd930b05d974cdb70953b6e7e128 /rational.c | |
parent | dc1c4e46758ace2c9e5e822df0d64b16bb564bb4 (diff) |
Using UNDEF_P macro
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6721
Diffstat (limited to 'rational.c')
-rw-r--r-- | rational.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rational.c b/rational.c index 48a9ab2ed2..dfe2ad74eb 100644 --- a/rational.c +++ b/rational.c @@ -2552,7 +2552,7 @@ nurat_convert(VALUE klass, VALUE numv, VALUE denv, int raise) VALUE a1 = numv, a2 = denv; int state; - assert(a1 != Qundef); + assert(!UNDEF_P(a1)); if (NIL_P(a1) || NIL_P(a2)) { if (!raise) return Qnil; @@ -2603,7 +2603,7 @@ nurat_convert(VALUE klass, VALUE numv, VALUE denv, int raise) a2 = string_to_r_strict(a2, raise); if (!raise && NIL_P(a2)) return Qnil; } - else if (a2 != Qundef && !rb_respond_to(a2, idTo_r)) { + else if (!UNDEF_P(a2) && !rb_respond_to(a2, idTo_r)) { VALUE tmp = rb_protect(rb_check_to_int, a2, NULL); rb_set_errinfo(Qnil); if (!NIL_P(tmp)) { @@ -2612,11 +2612,11 @@ nurat_convert(VALUE klass, VALUE numv, VALUE denv, int raise) } if (RB_TYPE_P(a1, T_RATIONAL)) { - if (a2 == Qundef || (k_exact_one_p(a2))) + if (UNDEF_P(a2) || (k_exact_one_p(a2))) return a1; } - if (a2 == Qundef) { + if (UNDEF_P(a2)) { if (!RB_INTEGER_TYPE_P(a1)) { if (!raise) { VALUE result = rb_protect(to_rational, a1, NULL); @@ -2666,7 +2666,7 @@ nurat_convert(VALUE klass, VALUE numv, VALUE denv, int raise) a1 = nurat_int_value(a1); - if (a2 == Qundef) { + if (UNDEF_P(a2)) { a2 = ONE; } else if (!k_integer_p(a2) && !raise) { |