From b66d7182b7030b1a69d6d72e0bc2e7b7cf7f8bb1 Mon Sep 17 00:00:00 2001 From: glass Date: Wed, 1 Jan 2014 16:40:11 +0000 Subject: [PATCH] * vm_eval.c (method_missing): use ALLOCV_N() instead of ALLOCA_N() and rb_ary_tmp_new(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ vm_eval.c | 13 +++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9669c7648..49fde41bae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jan 2 01:23:30 2014 Masaki Matsushita + + * vm_eval.c (method_missing): use ALLOCV_N() instead of + ALLOCA_N() and rb_ary_tmp_new(). + Thu Jan 2 00:53:16 2014 Masaki Matsushita * array.c (rb_ary_zip): use ALLOCV_N() instead of ALLOCA_N(). diff --git a/vm_eval.c b/vm_eval.c index c7d6f73313..82f5d3ffcf 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -695,7 +695,7 @@ raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj, static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status) { - VALUE *nargv, result, argv_ary = 0; + VALUE *nargv, result, work; rb_thread_t *th = GET_THREAD(); const rb_block_t *blockptr = th->passed_block; @@ -706,23 +706,16 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status) raise_method_missing(th, argc, argv, obj, call_status | NOEX_MISSING); } - if (argc < 0x100) { - nargv = ALLOCA_N(VALUE, argc + 1); - } - else { - argv_ary = rb_ary_tmp_new(argc + 1); - nargv = RARRAY_PTR(argv_ary); - } + nargv = ALLOCV_N(VALUE, work, argc + 1); nargv[0] = ID2SYM(id); MEMCPY(nargv + 1, argv, VALUE, argc); - if (argv_ary) rb_ary_set_len(argv_ary, argc + 1); if (rb_method_basic_definition_p(CLASS_OF(obj) , idMethodMissing)) { raise_method_missing(th, argc+1, nargv, obj, call_status | NOEX_MISSING); } th->passed_block = blockptr; result = rb_funcall2(obj, idMethodMissing, argc + 1, nargv); - if (argv_ary) rb_ary_clear(argv_ary); + if (work) ALLOCV_END(work); return result; }