Permalink
Browse files

* 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
  • Loading branch information...
mmasaki committed Jan 1, 2014
1 parent 56b0396 commit b66d7182b7030b1a69d6d72e0bc2e7b7cf7f8bb1
Showing with 8 additions and 10 deletions.
  1. +5 −0 ChangeLog
  2. +3 −10 vm_eval.c
View
@@ -1,3 +1,8 @@
+Thu Jan 2 01:23:30 2014 Masaki Matsushita <glass.saga@gmail.com>
+
+ * 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 <glass.saga@gmail.com>
* array.c (rb_ary_zip): use ALLOCV_N() instead of ALLOCA_N().
View
@@ -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;
}

0 comments on commit b66d718

Please sign in to comment.