From f94ed2ce4bcf201a4d16a85f0fdbbfce4ea20e35 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 25 Jun 2015 07:11:45 +0000 Subject: [PATCH] error.c: remove singleton method * error.c (rb_name_err_mesg_new): remove singleton method, and unused argument. * vm_eval.c (make_no_method_exception): call rb_name_err_mesg_new directly instead of constant lookup and method invocation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- error.c | 3 +-- vm_core.h | 2 +- vm_eval.c | 9 +-------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/error.c b/error.c index 70ebe6bb67..e41908ca35 100644 --- a/error.c +++ b/error.c @@ -1158,7 +1158,7 @@ static const rb_data_type_t name_err_mesg_data_type = { /* :nodoc: */ VALUE -rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method) +rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method) { VALUE result = TypedData_Wrap_Struct(rb_cNameErrorMesg, &name_err_mesg_data_type, 0); VALUE *ptr = ALLOC_N(VALUE, NAME_ERR_MESG_COUNT); @@ -1904,7 +1904,6 @@ Init_Exception(void) rb_define_method(rb_eNameError, "name", name_err_name, 0); rb_define_method(rb_eNameError, "receiver", name_err_receiver, 0); rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData); - rb_define_singleton_method(rb_cNameErrorMesg, "!", rb_name_err_mesg_new, NAME_ERR_MESG_COUNT); rb_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1); rb_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0); rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_dump, 1); diff --git a/vm_core.h b/vm_core.h index c0e63cd01e..72a1b2d908 100644 --- a/vm_core.h +++ b/vm_core.h @@ -1010,7 +1010,7 @@ typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE); rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp); rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp); int rb_vm_get_sourceline(const rb_control_frame_t *); -VALUE rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method); +VALUE rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method); void rb_vm_stack_to_heap(rb_thread_t *th); void ruby_thread_init_stack(rb_thread_t *th); int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp); diff --git a/vm_eval.c b/vm_eval.c index fd2277f448..bbc766617c 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -668,19 +668,12 @@ static VALUE make_no_method_exception(VALUE exc, const char *format, VALUE obj, int argc, const VALUE *argv) { int n = 0; - VALUE mesg; VALUE args[3]; if (!format) { format = "undefined method `%s' for %s"; } - mesg = rb_const_get(exc, rb_intern("message")); - if (rb_method_basic_definition_p(CLASS_OF(mesg), '!')) { - args[n++] = rb_name_err_mesg_new(mesg, rb_str_new2(format), obj, argv[0]); - } - else { - args[n++] = rb_funcall(mesg, '!', 3, rb_str_new2(format), obj, argv[0]); - } + args[n++] = rb_name_err_mesg_new(rb_str_new_cstr(format), obj, argv[0]); args[n++] = argv[0]; if (exc == rb_eNoMethodError) { args[n++] = rb_ary_new4(argc - 1, argv + 1);