1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2015-06-25 07:11:45 +00:00
parent f9c2adf310
commit f94ed2ce4b
3 changed files with 3 additions and 11 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);