From 8eb0c810b228df1f8352c005a7ae882ad4179b4b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 21 Nov 2014 16:11:55 +0000 Subject: get rid of inadvertent ID creation * object.c (rb_mod_const_get, rb_mod_const_defined): ditto. * variable.c (rb_const_missing, rb_mod_const_missing): call const_missing without new ID to get rid of inadvertent ID creation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 816088f40b..20991dbb40 100644 --- a/variable.c +++ b/variable.c @@ -1475,23 +1475,24 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name) UNREACHABLE; } -NORETURN(static void uninitialized_constant(VALUE, ID)); +NORETURN(static void uninitialized_constant(VALUE, VALUE)); static void -uninitialized_constant(VALUE klass, ID id) +uninitialized_constant(VALUE klass, VALUE name) { if (klass && rb_class_real(klass) != rb_cObject) - rb_name_error(id, "uninitialized constant %"PRIsVALUE"::%"PRIsVALUE"", - rb_class_name(klass), - QUOTE_ID(id)); + rb_name_error_str(name, "uninitialized constant %"PRIsVALUE"::% "PRIsVALUE"", + rb_class_name(klass), name); else { - rb_name_error(id, "uninitialized constant %"PRIsVALUE"", QUOTE_ID(id)); + rb_name_error_str(name, "uninitialized constant % "PRIsVALUE"", name); } } -static VALUE -const_missing(VALUE klass, ID id) +VALUE +rb_const_missing(VALUE klass, VALUE name) { - return rb_funcall(klass, rb_intern("const_missing"), 1, ID2SYM(id)); + VALUE value = rb_funcallv(klass, rb_intern("const_missing"), 1, &name); + rb_vm_inc_const_missing_count(); + return value; } @@ -1535,7 +1536,7 @@ VALUE rb_mod_const_missing(VALUE klass, VALUE name) { rb_vm_pop_cfunc_frame(); - uninitialized_constant(klass, rb_to_id(name)); + uninitialized_constant(klass, name); UNREACHABLE; } @@ -1876,9 +1877,7 @@ rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility) goto retry; } - value = const_missing(klass, id); - rb_vm_inc_const_missing_count(); - return value; + return rb_const_missing(klass, ID2SYM(id)); } VALUE -- cgit v1.2.3