summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-12-09 20:53:02 -0800
committerJeremy Evans <code@jeremyevans.net>2020-12-10 10:16:05 -0800
commit01b7d5acc702df22d306ae95f1a9c3096e63e624 (patch)
treeec42028540f04653d1022a1ed83d509df77bd723 /variable.c
parent4a559aa22537bbd2f17c7babb1aca48d1a3a4647 (diff)
Remove the uninitialized instance variable verbose mode warning
This speeds up all instance variable access, even when not in verbose mode. Uninitialized instance variable warnings were rarely helpful, and resulted in slower code if you wanted to avoid warnings when run in verbose mode. Implements [Feature #17055]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3879
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/variable.c b/variable.c
index 9f9813319e..81c0a7da2f 100644
--- a/variable.c
+++ b/variable.c
@@ -1217,14 +1217,8 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
VALUE
rb_ivar_get(VALUE obj, ID id)
{
- VALUE iv = rb_ivar_lookup(obj, id, Qundef);
+ VALUE iv = rb_ivar_lookup(obj, id, Qnil);
RB_DEBUG_COUNTER_INC(ivar_get_base);
-
- if (iv == Qundef) {
- if (RTEST(ruby_verbose))
- rb_warning("instance variable %"PRIsVALUE" not initialized", QUOTE_ID(id));
- iv = Qnil;
- }
return iv;
}
@@ -3526,8 +3520,6 @@ rb_iv_get(VALUE obj, const char *name)
ID id = rb_check_id_cstr(name, strlen(name), rb_usascii_encoding());
if (!id) {
- if (RTEST(ruby_verbose))
- rb_warning("instance variable %s not initialized", name);
return Qnil;
}
return rb_ivar_get(obj, id);