ruby-changes:38944
From: nobu <ko1@a...>
Date: Thu, 25 Jun 2015 16:12:00 +0900 (JST)
Subject: [ruby-changes:38944] nobu:r51025 (trunk): error.c: remove singleton method
nobu 2015-06-25 16:11:45 +0900 (Thu, 25 Jun 2015) New Revision: 51025 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51025 Log: 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. Modified files: trunk/error.c trunk/vm_core.h trunk/vm_eval.c Index: vm_core.h =================================================================== --- vm_core.h (revision 51024) +++ vm_core.h (revision 51025) @@ -1010,7 +1010,7 @@ typedef int rb_backtrace_iter_func(void https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1010 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); Index: vm_eval.c =================================================================== --- vm_eval.c (revision 51024) +++ vm_eval.c (revision 51025) @@ -668,19 +668,12 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L668 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); Index: error.c =================================================================== --- error.c (revision 51024) +++ error.c (revision 51025) @@ -1158,7 +1158,7 @@ static const rb_data_type_t name_err_mes https://github.com/ruby/ruby/blob/trunk/error.c#L1158 /* :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) https://github.com/ruby/ruby/blob/trunk/error.c#L1904 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/