diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-15 09:05:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-15 09:05:58 +0000 |
commit | 65daf7be940fbf446bfd528856946329db74c0d4 (patch) | |
tree | be939af79fb478efdca374460eb8b9a5d8eceb3e | |
parent | 35a29390197750abf97ef16fa0740e377764daef (diff) | |
download | ruby-65daf7be940fbf446bfd528856946329db74c0d4.tar.gz |
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
-rw-r--r-- | vm_args.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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; } |