Skip to content

Commit 1f4f6c9

Browse files
S-H-GAMELINKSnobu
authored andcommitted
Using UNDEF_P macro
1 parent dc1c4e4 commit 1f4f6c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+290
-290
lines changed

array.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4555,7 +4555,7 @@ take_items(VALUE obj, long n)
45554555
if (!NIL_P(result)) return rb_ary_subseq(result, 0, n);
45564556
result = rb_ary_new2(n);
45574557
args[0] = result; args[1] = (VALUE)n;
4558-
if (rb_check_block_call(obj, idEach, 0, 0, take_i, (VALUE)args) == Qundef)
4558+
if (UNDEF_P(rb_check_block_call(obj, idEach, 0, 0, take_i, (VALUE)args)))
45594559
rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE" (must respond to :each)",
45604560
rb_obj_class(obj));
45614561
return result;
@@ -5048,7 +5048,7 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
50485048
ARY_SET_LEN(ary, end);
50495049
}
50505050

5051-
if (item == Qundef) {
5051+
if (UNDEF_P(item)) {
50525052
VALUE v;
50535053
long i;
50545054

@@ -5505,7 +5505,7 @@ rb_ary_cmp(VALUE ary1, VALUE ary2)
55055505
if (NIL_P(ary2)) return Qnil;
55065506
if (ary1 == ary2) return INT2FIX(0);
55075507
v = rb_exec_recursive_paired(recursive_cmp, ary1, ary2, ary2);
5508-
if (v != Qundef) return v;
5508+
if (!UNDEF_P(v)) return v;
55095509
len = RARRAY_LEN(ary1) - RARRAY_LEN(ary2);
55105510
if (len == 0) return INT2FIX(0);
55115511
if (len > 0) return INT2FIX(1);
@@ -6068,7 +6068,7 @@ rb_ary_max(int argc, VALUE *argv, VALUE ary)
60686068
if (rb_block_given_p()) {
60696069
for (i = 0; i < RARRAY_LEN(ary); i++) {
60706070
v = RARRAY_AREF(ary, i);
6071-
if (result == Qundef || rb_cmpint(rb_yield_values(2, v, result), v, result) > 0) {
6071+
if (UNDEF_P(result) || rb_cmpint(rb_yield_values(2, v, result), v, result) > 0) {
60726072
result = v;
60736073
}
60746074
}
@@ -6090,7 +6090,7 @@ rb_ary_max(int argc, VALUE *argv, VALUE ary)
60906090
}
60916091
}
60926092
}
6093-
if (result == Qundef) return Qnil;
6093+
if (UNDEF_P(result)) return Qnil;
60946094
return result;
60956095
}
60966096

@@ -6237,7 +6237,7 @@ rb_ary_min(int argc, VALUE *argv, VALUE ary)
62376237
if (rb_block_given_p()) {
62386238
for (i = 0; i < RARRAY_LEN(ary); i++) {
62396239
v = RARRAY_AREF(ary, i);
6240-
if (result == Qundef || rb_cmpint(rb_yield_values(2, v, result), v, result) < 0) {
6240+
if (UNDEF_P(result) || rb_cmpint(rb_yield_values(2, v, result), v, result) < 0) {
62416241
result = v;
62426242
}
62436243
}
@@ -6259,7 +6259,7 @@ rb_ary_min(int argc, VALUE *argv, VALUE ary)
62596259
}
62606260
}
62616261
}
6262-
if (result == Qundef) return Qnil;
6262+
if (UNDEF_P(result)) return Qnil;
62636263
return result;
62646264
}
62656265

@@ -8148,7 +8148,7 @@ finish_exact_sum(long n, VALUE r, VALUE v, int z)
81488148
{
81498149
if (n != 0)
81508150
v = rb_fix_plus(LONG2FIX(n), v);
8151-
if (r != Qundef) {
8151+
if (!UNDEF_P(r)) {
81528152
v = rb_rational_plus(r, v);
81538153
}
81548154
else if (!n && z) {
@@ -8227,7 +8227,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
82278227
else if (RB_BIGNUM_TYPE_P(e))
82288228
v = rb_big_plus(e, v);
82298229
else if (RB_TYPE_P(e, T_RATIONAL)) {
8230-
if (r == Qundef)
8230+
if (UNDEF_P(r))
82318231
r = e;
82328232
else
82338233
r = rb_rational_plus(r, e);

class.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ push_subclass_entry_to_list(VALUE super, VALUE klass)
6464
void
6565
rb_class_subclass_add(VALUE super, VALUE klass)
6666
{
67-
if (super && super != Qundef) {
67+
if (super && !UNDEF_P(super)) {
6868
rb_subclass_entry_t *entry = push_subclass_entry_to_list(super, klass);
6969
RCLASS_SUBCLASS_ENTRY(klass) = entry;
7070
}
@@ -277,7 +277,7 @@ rb_class_update_superclasses(VALUE klass)
277277
VALUE super = RCLASS_SUPER(klass);
278278

279279
if (!RB_TYPE_P(klass, T_CLASS)) return;
280-
if (super == Qundef) return;
280+
if (UNDEF_P(super)) return;
281281

282282
// If the superclass array is already built
283283
if (RCLASS_SUPERCLASSES(klass))
@@ -608,7 +608,7 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
608608
arg.klass = clone;
609609
rb_id_table_foreach(RCLASS_CONST_TBL(klass), clone_const_i, &arg);
610610
}
611-
if (attach != Qundef) {
611+
if (!UNDEF_P(attach)) {
612612
rb_singleton_class_attached(clone, attach);
613613
}
614614
RCLASS_M_TBL_INIT(clone);

compar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ VALUE
5050
rb_invcmp(VALUE x, VALUE y)
5151
{
5252
VALUE invcmp = rb_exec_recursive(invcmp_recursive, x, y);
53-
if (invcmp == Qundef || NIL_P(invcmp)) {
53+
if (UNDEF_P(invcmp) || NIL_P(invcmp)) {
5454
return Qnil;
5555
}
5656
else {

compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4820,7 +4820,7 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
48204820
const NODE *val = vals->nd_head;
48214821
VALUE lit = rb_node_case_when_optimizable_literal(val);
48224822

4823-
if (lit == Qundef) {
4823+
if (UNDEF_P(lit)) {
48244824
only_special_literals = 0;
48254825
}
48264826
else if (NIL_P(rb_hash_lookup(literals, lit))) {
@@ -7394,7 +7394,7 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
73947394
ADD_LABEL(ret, end_label);
73957395
ADD_ADJUST_RESTORE(ret, adjust_label);
73967396

7397-
if (node->nd_state == Qundef) {
7397+
if (UNDEF_P(node->nd_state)) {
73987398
/* ADD_INSN(ret, line_node, putundef); */
73997399
COMPILE_ERROR(ERROR_ARGS "unsupported: putundef");
74007400
return COMPILE_NG;

complex.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
561561
if (!NIL_P(opts)) {
562562
raise = rb_opts_exception_p(opts, raise);
563563
}
564-
if (argc > 0 && CLASS_OF(a1) == rb_cComplex && a2 == Qundef) {
564+
if (argc > 0 && CLASS_OF(a1) == rb_cComplex && UNDEF_P(a2)) {
565565
return a1;
566566
}
567567
return nucomp_convert(rb_cComplex, a1, a2, raise);
@@ -2107,11 +2107,11 @@ nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise)
21072107
}
21082108

21092109
if (RB_TYPE_P(a1, T_COMPLEX)) {
2110-
if (a2 == Qundef || (k_exact_zero_p(a2)))
2110+
if (UNDEF_P(a2) || (k_exact_zero_p(a2)))
21112111
return a1;
21122112
}
21132113

2114-
if (a2 == Qundef) {
2114+
if (UNDEF_P(a2)) {
21152115
if (k_numeric_p(a1) && !f_real_p(a1))
21162116
return a1;
21172117
/* should raise exception for consistency */
@@ -2133,7 +2133,7 @@ nucomp_convert(VALUE klass, VALUE a1, VALUE a2, int raise)
21332133
int argc;
21342134
VALUE argv2[2];
21352135
argv2[0] = a1;
2136-
if (a2 == Qundef) {
2136+
if (UNDEF_P(a2)) {
21372137
argv2[1] = Qnil;
21382138
argc = 1;
21392139
}

cont.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
18311831
/* push ensure stack */
18321832
for (j = 0; j < i; j++) {
18331833
func = lookup_rollback_func(target[i - j - 1].e_proc);
1834-
if ((VALUE)func != Qundef) {
1834+
if (!UNDEF_P((VALUE)func)) {
18351835
(*func)(target[i - j - 1].data2);
18361836
}
18371837
}
@@ -2058,11 +2058,11 @@ rb_fiber_initialize_kw(int argc, VALUE* argv, VALUE self, int kw_splat)
20582058
argc = rb_scan_args_kw(kw_splat, argc, argv, ":", &options);
20592059
rb_get_kwargs(options, fiber_initialize_keywords, 0, 2, arguments);
20602060

2061-
if (arguments[0] != Qundef) {
2061+
if (!UNDEF_P(arguments[0])) {
20622062
blocking = arguments[0];
20632063
}
20642064

2065-
if (arguments[1] != Qundef) {
2065+
if (!UNDEF_P(arguments[1])) {
20662066
pool = arguments[1];
20672067
}
20682068
}

dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,7 +2932,7 @@ dir_globs(VALUE args, VALUE base, int flags)
29322932
static VALUE
29332933
dir_glob_option_base(VALUE base)
29342934
{
2935-
if (base == Qundef || NIL_P(base)) {
2935+
if (UNDEF_P(base) || NIL_P(base)) {
29362936
return Qnil;
29372937
}
29382938
#if USE_OPENDIR_AT
@@ -3343,7 +3343,7 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
33433343

33443344
result = (VALUE)rb_thread_call_without_gvl(nogvl_dir_empty_p, (void *)path,
33453345
RUBY_UBF_IO, 0);
3346-
if (result == Qundef) {
3346+
if (UNDEF_P(result)) {
33473347
rb_sys_fail_path(orig);
33483348
}
33493349
return result;

0 commit comments

Comments
 (0)