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

vm_args.c: cache procs

* vm_args.c (vm_caller_setup_arg_block): cache proc with
  refinements.  [Feature #9451]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-10-15 09:05:58 +00:00
parent 35a2939019
commit 65daf7be94

View file

@ -828,7 +828,14 @@ vm_caller_setup_arg_block(const rb_thread_t *th, rb_control_frame_t *reg_cfp,
if (SYMBOL_P(block_code) && rb_method_basic_definition_p(rb_cSymbol, idTo_proc)) {
const rb_cref_t *cref = vm_env_cref(reg_cfp->ep);
if (cref && !NIL_P(cref->refinements)) {
block_code = rb_func_proc_new(refine_sym_proc_call, block_code);
VALUE ref = cref->refinements;
VALUE func = rb_hash_lookup(ref, block_code);
if (NIL_P(func)) {
/* TODO: limit cached funcs */
func = rb_func_proc_new(refine_sym_proc_call, block_code);
rb_hash_aset(ref, block_code, func);
}
block_code = func;
}
calling->block_handler = block_code;
}