aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--array.c6
-rw-r--r--compile.c2
-rw-r--r--dir.c2
-rw-r--r--enum.c4
-rw-r--r--error.c2
-rw-r--r--gc.c8
-rw-r--r--io.c2
-rw-r--r--iseq.c8
-rw-r--r--marshal.c2
-rw-r--r--range.c4
-rw-r--r--re.c10
-rw-r--r--struct.c4
-rw-r--r--thread.c2
-rw-r--r--transcode.c4
-rw-r--r--vm.c14
-rw-r--r--vm_args.c2
-rw-r--r--vm_backtrace.c6
-rw-r--r--vm_insnhelper.c4
18 files changed, 43 insertions, 43 deletions
diff --git a/array.c b/array.c
index 63d63aa17f..3e949cfa79 100644
--- a/array.c
+++ b/array.c
@@ -3466,7 +3466,7 @@ rb_ary_bsearch_index(VALUE ary)
satisfied = 1;
smaller = 1;
}
- else if (v == Qfalse || v == Qnil) {
+ else if (!RTEST(v)) {
smaller = 0;
}
else if (rb_obj_is_kind_of(v, rb_cNumeric)) {
@@ -6479,7 +6479,7 @@ rb_ary_cycle_size(VALUE self, VALUE args, VALUE eobj)
n = RARRAY_AREF(args, 0);
}
if (RARRAY_LEN(self) == 0) return INT2FIX(0);
- if (n == Qnil) return DBL2NUM(HUGE_VAL);
+ if (NIL_P(n)) return DBL2NUM(HUGE_VAL);
mul = NUM2LONG(n);
if (mul <= 0) return INT2FIX(0);
n = LONG2FIX(mul);
@@ -7344,7 +7344,7 @@ rb_ary_drop(VALUE ary, VALUE n)
}
result = rb_ary_subseq(ary, pos, RARRAY_LEN(ary));
- if (result == Qnil) result = rb_ary_new();
+ if (NIL_P(result)) result = rb_ary_new();
return result;
}
diff --git a/compile.c b/compile.c
index 268bd8b6a6..9d34ccbf05 100644
--- a/compile.c
+++ b/compile.c
@@ -9934,7 +9934,7 @@ iseq_build_from_ary_exception(rb_iseq_t *iseq, struct st_table *labels_table,
rb_raise(rb_eSyntaxError, "wrong exception entry");
}
type = get_exception_sym2type(RARRAY_AREF(v, 0));
- if (RARRAY_AREF(v, 1) == Qnil) {
+ if (NIL_P(RARRAY_AREF(v, 1))) {
eiseq = NULL;
}
else {
diff --git a/dir.c b/dir.c
index 32bce9f2b6..4e552d772a 100644
--- a/dir.c
+++ b/dir.c
@@ -989,7 +989,7 @@ chdir_yield(VALUE v)
dir_chdir(args->new_path);
args->done = TRUE;
chdir_blocking++;
- if (chdir_thread == Qnil)
+ if (NIL_P(chdir_thread))
chdir_thread = rb_thread_current();
return rb_yield(args->new_path);
}
diff --git a/enum.c b/enum.c
index 7528eb88c0..b1a21b62eb 100644
--- a/enum.c
+++ b/enum.c
@@ -2921,7 +2921,7 @@ enum_each_slice_size(VALUE obj, VALUE args, VALUE eobj)
if (slice_size <= 0) rb_raise(rb_eArgError, "invalid slice size");
size = enum_size(obj, 0, 0);
- if (size == Qnil) return Qnil;
+ if (NIL_P(size)) return Qnil;
if (RB_FLOAT_TYPE_P(size) && RTEST(rb_funcall(size, infinite_p, 0))) {
return size;
}
@@ -3003,7 +3003,7 @@ enum_each_cons_size(VALUE obj, VALUE args, VALUE eobj)
if (cons_size <= 0) rb_raise(rb_eArgError, "invalid size");
size = enum_size(obj, 0, 0);
- if (size == Qnil) return Qnil;
+ if (NIL_P(size)) return Qnil;
n = add_int(size, 1 - cons_size);
return (OPTIMIZED_CMP(n, zero, cmp_opt) == -1) ? zero : n;
diff --git a/error.c b/error.c
index 84902204d2..65bf1721a2 100644
--- a/error.c
+++ b/error.c
@@ -1986,7 +1986,7 @@ name_err_mesg_to_str(VALUE obj)
break;
default:
d = rb_protect(name_err_mesg_receiver_name, obj, &state);
- if (state || d == Qundef || d == Qnil)
+ if (state || d == Qundef || NIL_P(d))
d = rb_protect(rb_inspect, obj, &state);
if (state) {
rb_set_errinfo(Qnil);
diff --git a/gc.c b/gc.c
index 8a49a6453e..76a5df27a6 100644
--- a/gc.c
+++ b/gc.c
@@ -4354,7 +4354,7 @@ id2ref(VALUE objid)
ptr = NUM2PTR(objid);
if (ptr == Qtrue) return Qtrue;
if (ptr == Qfalse) return Qfalse;
- if (ptr == Qnil) return Qnil;
+ if (NIL_P(ptr)) return Qnil;
if (FIXNUM_P(ptr)) return (VALUE)ptr;
if (FLONUM_P(ptr)) return (VALUE)ptr;
@@ -4802,7 +4802,7 @@ count_objects(int argc, VALUE *argv, VALUE os)
total += page->total_slots;
}
- if (hash == Qnil) {
+ if (NIL_P(hash)) {
hash = rb_hash_new();
}
else if (!RHASH_EMPTY_P(hash)) {
@@ -8784,7 +8784,7 @@ rb_gc_register_mark_object(VALUE obj)
VALUE ary_ary = GET_VM()->mark_object_ary;
VALUE ary = rb_ary_last(0, 0, ary_ary);
- if (ary == Qnil || RARRAY_LEN(ary) >= MARK_OBJECT_ARY_BUCKET_SIZE) {
+ if (NIL_P(ary) || RARRAY_LEN(ary) >= MARK_OBJECT_ARY_BUCKET_SIZE) {
ary = rb_ary_tmp_new(MARK_OBJECT_ARY_BUCKET_SIZE);
rb_ary_push(ary_ary, ary);
}
@@ -10383,7 +10383,7 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
rb_raise(rb_eTypeError, "non-hash or symbol given");
}
- if (sym_major_by == Qnil) {
+ if (NIL_P(sym_major_by)) {
#define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
S(major_by);
S(gc_by);
diff --git a/io.c b/io.c
index 0e11b8ad9a..5ad2b6474c 100644
--- a/io.c
+++ b/io.c
@@ -10634,7 +10634,7 @@ rb_io_s_pipe(int argc, VALUE *argv, VALUE klass)
extract_binmode(opt, &fmode);
- if ((fmode & FMODE_BINMODE) && v1 == Qnil) {
+ if ((fmode & FMODE_BINMODE) && NIL_P(v1)) {
rb_io_ascii8bit_binmode(r);
rb_io_ascii8bit_binmode(w);
}
diff --git a/iseq.c b/iseq.c
index d3bd4a22f3..e04642fd92 100644
--- a/iseq.c
+++ b/iseq.c
@@ -503,7 +503,7 @@ rb_iseq_pathobj_new(VALUE path, VALUE realpath)
{
VALUE pathobj;
VM_ASSERT(RB_TYPE_P(path, T_STRING));
- VM_ASSERT(realpath == Qnil || RB_TYPE_P(realpath, T_STRING));
+ VM_ASSERT(NIL_P(realpath) || RB_TYPE_P(realpath, T_STRING));
if (path == realpath ||
(!NIL_P(realpath) && rb_str_cmp(path, realpath) == 0)) {
@@ -759,7 +759,7 @@ rb_iseq_make_compile_option(rb_compile_option_t *option, VALUE opt)
static void
make_compile_option(rb_compile_option_t *option, VALUE opt)
{
- if (opt == Qnil) {
+ if (NIL_P(opt)) {
*option = COMPILE_OPTION_DEFAULT;
}
else if (opt == Qfalse) {
@@ -2413,7 +2413,7 @@ iseq_iterate_children(const rb_iseq_t *iseq, void (*iter_func)(const rb_iseq_t *
UNALIGNED_MEMBER_PTR(body->catch_table, entries[i]);
child = entry->iseq;
if (child) {
- if (rb_hash_aref(all_children, (VALUE)child) == Qnil) {
+ if (NIL_P(rb_hash_aref(all_children, (VALUE)child))) {
rb_hash_aset(all_children, (VALUE)child, Qtrue);
(*iter_func)(child, data);
}
@@ -2432,7 +2432,7 @@ iseq_iterate_children(const rb_iseq_t *iseq, void (*iter_func)(const rb_iseq_t *
case TS_ISEQ:
child = (const rb_iseq_t *)code[i+j+1];
if (child) {
- if (rb_hash_aref(all_children, (VALUE)child) == Qnil) {
+ if (NIL_P(rb_hash_aref(all_children, (VALUE)child))) {
rb_hash_aset(all_children, (VALUE)child, Qtrue);
(*iter_func)(child, data);
}
diff --git a/marshal.c b/marshal.c
index acaa27a419..d8fcf56685 100644
--- a/marshal.c
+++ b/marshal.c
@@ -777,7 +777,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
return;
}
- if (obj == Qnil) {
+ if (NIL_P(obj)) {
w_byte(TYPE_NIL, arg);
}
else if (obj == Qtrue) {
diff --git a/range.c b/range.c
index 6f44e82600..31f734181d 100644
--- a/range.c
+++ b/range.c
@@ -642,7 +642,7 @@ bsearch_integer_range(VALUE beg, VALUE end, int excl)
satisfied = val; \
smaller = 1; \
} \
- else if (v == Qfalse || v == Qnil) { \
+ else if (!RTEST(v)) { \
smaller = 0; \
} \
else if (rb_obj_is_kind_of(v, rb_cNumeric)) { \
@@ -1952,7 +1952,7 @@ r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val)
}
val_max = rb_rescue2(r_call_max, val, 0, Qnil, rb_eTypeError, (VALUE)0);
- if (val_max == Qnil) return FALSE;
+ if (NIL_P(val_max)) return FALSE;
return r_less(end, val_max) >= 0;
}
diff --git a/re.c b/re.c
index 58e43f9c29..cccedc9869 100644
--- a/re.c
+++ b/re.c
@@ -1557,7 +1557,7 @@ rb_reg_prepare_re0(VALUE re, VALUE str, onig_errmsg_buffer err)
pattern, pattern + RREGEXP_SRC_LEN(re), enc,
&fixed_enc, err);
- if (unescaped == Qnil) {
+ if (NIL_P(unescaped)) {
rb_raise(rb_eArgError, "regexp preprocess failed: %s", err);
}
@@ -2357,7 +2357,7 @@ match_inspect(VALUE match)
rb_str_buf_cat2(str, ":");
}
v = rb_reg_nth_match(i, match);
- if (v == Qnil)
+ if (NIL_P(v))
rb_str_buf_cat2(str, "nil");
else
rb_str_buf_append(str, rb_str_inspect(v));
@@ -2800,7 +2800,7 @@ rb_reg_check_preprocess(VALUE str)
buf = rb_reg_preprocess(p, end, enc, &fixed_enc, err);
RB_GC_GUARD(str);
- if (buf == Qnil) {
+ if (NIL_P(buf)) {
return rb_reg_error_desc(str, 0, err);
}
return Qnil;
@@ -2841,7 +2841,7 @@ rb_reg_preprocess_dregexp(VALUE ary, int options)
buf = rb_reg_preprocess(p, end, src_enc, &fixed_enc, err);
- if (buf == Qnil)
+ if (NIL_P(buf))
rb_raise(rb_eArgError, "%s", err);
if (fixed_enc != 0) {
@@ -2887,7 +2887,7 @@ rb_reg_initialize(VALUE obj, const char *s, long len, rb_encoding *enc,
}
unescaped = rb_reg_preprocess(s, s+len, enc, &fixed_enc, err);
- if (unescaped == Qnil)
+ if (NIL_P(unescaped))
return -1;
if (fixed_enc) {
diff --git a/struct.c b/struct.c
index 5aa70edf24..6fc5bf1048 100644
--- a/struct.c
+++ b/struct.c
@@ -712,7 +712,7 @@ struct_hash_set_i(VALUE key, VALUE val, VALUE arg)
struct struct_hash_set_arg *args = (struct struct_hash_set_arg *)arg;
int i = rb_struct_pos(args->self, &key);
if (i < 0) {
- if (args->unknown_keywords == Qnil) {
+ if (NIL_P(args->unknown_keywords)) {
args->unknown_keywords = rb_ary_new();
}
rb_ary_push(args->unknown_keywords, key);
@@ -754,7 +754,7 @@ rb_struct_initialize_m(int argc, const VALUE *argv, VALUE self)
if (n < argc) {
rb_raise(rb_eArgError, "struct size differs");
}
- if (keyword_init == Qnil && argc == 1 && RB_TYPE_P(argv[0], T_HASH) && rb_keyword_given_p()) {
+ if (NIL_P(keyword_init) && argc == 1 && RB_TYPE_P(argv[0], T_HASH) && rb_keyword_given_p()) {
rb_warn("Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. "\
"Please use a Hash literal like .new({k: v}) instead of .new(k: v).");
}
diff --git a/thread.c b/thread.c
index 55d8ca671e..86676d7bc6 100644
--- a/thread.c
+++ b/thread.c
@@ -1330,7 +1330,7 @@ thread_join_m(int argc, VALUE *argv, VALUE self)
* This supports INFINITY and negative values, so we can't use
* rb_time_interval right now...
*/
- if (timeout == Qnil) {
+ if (NIL_P(timeout)) {
/* unlimited */
}
else if (FIXNUM_P(timeout)) {
diff --git a/transcode.c b/transcode.c
index ec0507ca80..0681288346 100644
--- a/transcode.c
+++ b/transcode.c
@@ -2102,7 +2102,7 @@ make_econv_exception(rb_econv_t *ec)
dumped = rb_sprintf("U+%04X", cc);
}
}
- if (dumped == Qnil)
+ if (NIL_P(dumped))
dumped = rb_str_dump(bytes);
if (strcmp(ec->last_error.source_encoding,
ec->source_encoding_name) == 0 &&
@@ -3121,7 +3121,7 @@ search_convpath_i(const char *sname, const char *dname, int depth, void *arg)
VALUE *ary_p = arg;
VALUE v;
- if (*ary_p == Qnil) {
+ if (NIL_P(*ary_p)) {
*ary_p = rb_ary_new();
}
diff --git a/vm.c b/vm.c
index f6b0f94690..5a1756e33a 100644
--- a/vm.c
+++ b/vm.c
@@ -3819,11 +3819,11 @@ vm_analysis_insn(int insn)
CONST_ID(usage_hash, "USAGE_ANALYSIS_INSN");
CONST_ID(bigram_hash, "USAGE_ANALYSIS_INSN_BIGRAM");
uh = rb_const_get(rb_cRubyVM, usage_hash);
- if ((ihash = rb_hash_aref(uh, INT2FIX(insn))) == Qnil) {
+ if (NIL_P(ihash = rb_hash_aref(uh, INT2FIX(insn)))) {
ihash = rb_hash_new();
HASH_ASET(uh, INT2FIX(insn), ihash);
}
- if ((cv = rb_hash_aref(ihash, INT2FIX(-1))) == Qnil) {
+ if (NIL_P(cv = rb_hash_aref(ihash, INT2FIX(-1)))) {
cv = INT2FIX(0);
}
HASH_ASET(ihash, INT2FIX(-1), INT2FIX(FIX2INT(cv) + 1));
@@ -3839,7 +3839,7 @@ vm_analysis_insn(int insn)
bi = rb_ary_new4(2, &ary[0]);
uh = rb_const_get(rb_cRubyVM, bigram_hash);
- if ((cv = rb_hash_aref(uh, bi)) == Qnil) {
+ if (NIL_P(cv = rb_hash_aref(uh, bi))) {
cv = INT2FIX(0);
}
HASH_ASET(uh, bi, INT2FIX(FIX2INT(cv) + 1));
@@ -3861,11 +3861,11 @@ vm_analysis_operand(int insn, int n, VALUE op)
CONST_ID(usage_hash, "USAGE_ANALYSIS_INSN");
uh = rb_const_get(rb_cRubyVM, usage_hash);
- if ((ihash = rb_hash_aref(uh, INT2FIX(insn))) == Qnil) {
+ if (NIL_P(ihash = rb_hash_aref(uh, INT2FIX(insn)))) {
ihash = rb_hash_new();
HASH_ASET(uh, INT2FIX(insn), ihash);
}
- if ((ophash = rb_hash_aref(ihash, INT2FIX(n))) == Qnil) {
+ if (NIL_P(ophash = rb_hash_aref(ihash, INT2FIX(n)))) {
ophash = rb_hash_new();
HASH_ASET(ihash, INT2FIX(n), ophash);
}
@@ -3873,7 +3873,7 @@ vm_analysis_operand(int insn, int n, VALUE op)
valstr = rb_insn_operand_intern(GET_EC()->cfp->iseq, insn, n, op, 0, 0, 0, 0);
/* set count */
- if ((cv = rb_hash_aref(ophash, valstr)) == Qnil) {
+ if (NIL_P(cv = rb_hash_aref(ophash, valstr))) {
cv = INT2FIX(0);
}
HASH_ASET(ophash, valstr, INT2FIX(FIX2INT(cv) + 1));
@@ -3917,7 +3917,7 @@ vm_analysis_register(int reg, int isset)
valstr = syms[reg][isset];
uh = rb_const_get(rb_cRubyVM, usage_hash);
- if ((cv = rb_hash_aref(uh, valstr)) == Qnil) {
+ if (NIL_P(cv = rb_hash_aref(uh, valstr))) {
cv = INT2FIX(0);
}
HASH_ASET(uh, valstr, INT2FIX(FIX2INT(cv) + 1));
diff --git a/vm_args.c b/vm_args.c
index 0233671409..58ec4a0826 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -604,7 +604,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
case arg_setup_method:
break; /* do nothing special */
case arg_setup_block:
- if (given_argc == (keyword_hash == Qnil ? 1 : 2) &&
+ if (given_argc == (NIL_P(keyword_hash) ? 1 : 2) &&
allow_autosplat &&
(min_argc > 0 || iseq->body->param.opt_num > 1) &&
!iseq->body->param.flags.ambiguous_param0 &&
diff --git a/vm_backtrace.c b/vm_backtrace.c
index fc9f701d09..8294d218a4 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -1495,7 +1495,7 @@ rb_profile_frames(int start, int limit, VALUE *buff, int *lines)
static const rb_iseq_t *
frame2iseq(VALUE frame)
{
- if (frame == Qnil) return NULL;
+ if (NIL_P(frame)) return NULL;
if (RB_TYPE_P(frame, T_IMEMO)) {
switch (imemo_type(frame)) {
@@ -1528,7 +1528,7 @@ rb_profile_frame_path(VALUE frame)
static const rb_callable_method_entry_t *
cframe(VALUE frame)
{
- if (frame == Qnil) return NULL;
+ if (NIL_P(frame)) return NULL;
if (RB_TYPE_P(frame, T_IMEMO)) {
switch (imemo_type(frame)) {
@@ -1589,7 +1589,7 @@ rb_profile_frame_first_lineno(VALUE frame)
static VALUE
frame2klass(VALUE frame)
{
- if (frame == Qnil) return Qnil;
+ if (NIL_P(frame)) return Qnil;
if (RB_TYPE_P(frame, T_IMEMO)) {
const rb_callable_method_entry_t *cme = (rb_callable_method_entry_t *)frame;
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 177616b141..6c2ba1513d 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -962,7 +962,7 @@ vm_get_ev_const(rb_execution_context_t *ec, VALUE orig_klass, ID id, bool allow_
void rb_const_warn_if_deprecated(const rb_const_entry_t *ce, VALUE klass, ID id);
VALUE val;
- if (orig_klass == Qnil && allow_nil) {
+ if (NIL_P(orig_klass) && allow_nil) {
/* in current lexical scope */
const rb_cref_t *root_cref = vm_get_cref(ec->cfp->ep);
const rb_cref_t *cref;
@@ -5232,7 +5232,7 @@ VALUE rb_false(VALUE obj);
static VALUE
vm_opt_nil_p(const rb_iseq_t *iseq, CALL_DATA cd, VALUE recv)
{
- if (recv == Qnil &&
+ if (NIL_P(recv) &&
BASIC_OP_UNREDEFINED_P(BOP_NIL_P, NIL_REDEFINED_OP_FLAG)) {
return Qtrue;
}