From 1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6 Mon Sep 17 00:00:00 2001 From: S-H-GAMELINKS Date: Tue, 15 Nov 2022 13:24:08 +0900 Subject: Using UNDEF_P macro --- variable.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 93abdac454..daae90396e 100644 --- a/variable.c +++ b/variable.c @@ -281,7 +281,7 @@ rb_path_to_class(VALUE pathname) goto undefined_class; } c = rb_const_search(c, id, TRUE, FALSE, FALSE); - if (c == Qundef) goto undefined_class; + if (UNDEF_P(c)) goto undefined_class; if (!rb_namespace_p(c)) { rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module", pathname); @@ -1108,7 +1108,7 @@ gen_ivtbl_count(const struct gen_ivtbl *ivtbl) size_t n = 0; for (i = 0; i < ivtbl->numiv; i++) { - if (ivtbl->ivptr[i] != Qundef) { + if (!UNDEF_P(ivtbl->ivptr[i])) { n++; } } @@ -1598,7 +1598,7 @@ iterate_over_shapes_with_callback(rb_shape_t *shape, rb_ivar_foreach_callback_fu break; } VALUE val = iv_list[shape->next_iv_index - 1]; - if (val != Qundef) { + if (!UNDEF_P(val)) { callback(shape->edge_name, val, itr_data->arg); } return; @@ -1756,7 +1756,7 @@ rb_ivar_count(VALUE obj) st_index_t i, count, num = ROBJECT_IV_COUNT(obj); const VALUE *const ivptr = ROBJECT_IVPTR(obj); for (i = count = 0; i < num; ++i) { - if (ivptr[i] != Qundef) { + if (!UNDEF_P(ivptr[i])) { count++; } } @@ -1773,7 +1773,7 @@ rb_ivar_count(VALUE obj) st_index_t i, num = rb_shape_get_shape(obj)->next_iv_index; const VALUE *const ivptr = RCLASS_IVPTR(obj); for (i = count = 0; i < num; ++i) { - if (ivptr[i] != Qundef) { + if (!UNDEF_P(ivptr[i])) { count++; } } @@ -2283,7 +2283,7 @@ autoload_synchronized(VALUE _arguments) struct autoload_arguments *arguments = (struct autoload_arguments *)_arguments; rb_const_entry_t *constant_entry = rb_const_lookup(arguments->module, arguments->name); - if (constant_entry && constant_entry->value != Qundef) { + if (constant_entry && !UNDEF_P(constant_entry->value)) { return Qfalse; } @@ -2468,7 +2468,7 @@ autoloading_const_entry(VALUE mod, ID id) // Check if it's being loaded by the current thread/fiber: if (autoload_by_current(ele)) { - if (ac->value != Qundef) { + if (!UNDEF_P(ac->value)) { return ac; } } @@ -2482,7 +2482,7 @@ autoload_defined_p(VALUE mod, ID id) rb_const_entry_t *ce = rb_const_lookup(mod, id); // If there is no constant or the constant is not undefined (special marker for autoloading): - if (!ce || ce->value != Qundef) { + if (!ce || !UNDEF_P(ce->value)) { // We are not autoloading: return 0; } @@ -2578,7 +2578,7 @@ autoload_apply_constants(VALUE _arguments) // Iterate over all constants and assign them: ccan_list_for_each_safe(&arguments->autoload_data->constants, autoload_const, next, cnode) { - if (autoload_const->value != Qundef) { + if (!UNDEF_P(autoload_const->value)) { autoload_const_set(autoload_const); } } @@ -2617,7 +2617,7 @@ autoload_try_load(VALUE _arguments) // After we loaded the feature, if the constant is not defined, we remove it completely: rb_const_entry_t *ce = rb_const_lookup(arguments->module, arguments->name); - if (!ce || ce->value == Qundef) { + if (!ce || UNDEF_P(ce->value)) { result = Qfalse; rb_const_remove(arguments->module, arguments->name); @@ -2652,7 +2652,7 @@ rb_autoload_load(VALUE module, ID name) rb_const_entry_t *ce = rb_const_lookup(module, name); // We bail out as early as possible without any synchronisation: - if (!ce || ce->value != Qundef) { + if (!ce || !UNDEF_P(ce->value)) { return Qfalse; } @@ -2725,7 +2725,7 @@ static VALUE rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility) { VALUE c = rb_const_search(klass, id, exclude, recurse, visibility); - if (c != Qundef) { + if (!UNDEF_P(c)) { if (UNLIKELY(!rb_ractor_main_p())) { if (!rb_ractor_shareable_p(c)) { rb_raise(rb_eRactorIsolationError, "can not access non-shareable objects in constant %"PRIsVALUE"::%s by non-main Ractor.", rb_class_path(klass), rb_id2name(id)); @@ -2769,7 +2769,7 @@ rb_const_search_from(VALUE klass, ID id, int exclude, int recurse, int visibilit } rb_const_warn_if_deprecated(ce, tmp, id); value = ce->value; - if (value == Qundef) { + if (UNDEF_P(value)) { struct autoload_const *ac; if (am == tmp) break; am = tmp; @@ -2798,7 +2798,7 @@ rb_const_search(VALUE klass, ID id, int exclude, int recurse, int visibility) if (klass == rb_cObject) exclude = FALSE; value = rb_const_search_from(klass, id, exclude, recurse, visibility); - if (value != Qundef) return value; + if (!UNDEF_P(value)) return value; if (exclude) return value; if (BUILTIN_TYPE(klass) != T_MODULE) return value; /* search global const too, if klass is a module */ @@ -2935,7 +2935,7 @@ rb_const_remove(VALUE mod, ID id) val = ce->value; - if (val == Qundef) { + if (UNDEF_P(val)) { autoload_delete(mod, id); val = Qnil; } @@ -3092,7 +3092,7 @@ rb_const_defined_0(VALUE klass, ID id, int exclude, int recurse, int visibility) if (visibility && RB_CONST_PRIVATE_P(ce)) { return (int)Qfalse; } - if (ce->value == Qundef && !check_autoload_required(tmp, id, 0) && + if (UNDEF_P(ce->value) && !check_autoload_required(tmp, id, 0) && !rb_autoloading_value(tmp, id, NULL, NULL)) return (int)Qfalse; @@ -3298,7 +3298,7 @@ const_tbl_update(struct autoload_const *ac, int autoload_force) if (rb_id_table_lookup(tbl, id, &value)) { ce = (rb_const_entry_t *)value; - if (ce->value == Qundef) { + if (UNDEF_P(ce->value)) { RUBY_ASSERT_CRITICAL_SECTION_ENTER(); VALUE file = ac->file; int line = ac->line; @@ -3398,7 +3398,7 @@ set_const_visibility(VALUE mod, int argc, const VALUE *argv, if ((ce = rb_const_lookup(mod, id))) { ce->flag &= ~mask; ce->flag |= flag; - if (ce->value == Qundef) { + if (UNDEF_P(ce->value)) { struct autoload_data *ele; ele = autoload_data_for_named_constant(mod, id, &ac); @@ -3508,7 +3508,7 @@ cvar_lookup_at(VALUE klass, ID id, st_data_t *v) } VALUE n = rb_ivar_lookup(klass, id, Qundef); - if (n == Qundef) return 0; + if (UNDEF_P(n)) return 0; if (v) *v = n; return 1; @@ -3838,7 +3838,7 @@ rb_mod_remove_cvar(VALUE mod, VALUE name) } rb_check_frozen(mod); val = rb_ivar_delete(mod, id, Qundef); - if (val != Qundef) { + if (!UNDEF_P(val)) { return (VALUE)val; } if (rb_cvar_defined(mod, id)) { -- cgit v1.2.3