diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-04-05 13:58:20 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-04-05 13:58:20 +0900 |
| commit | d26f03b44640dbcd1e97894a9840549127f1ac0a (patch) | |
| tree | a2a7654559c82f068f531076f62d940b5c3214cd /mrbgems/mruby-method | |
| parent | dd1c100b840dfc024040f677fc536141b06853de (diff) | |
| parent | ed41bbb199fb614bb68423d19d26c09c5027319a (diff) | |
| download | mruby-d26f03b44640dbcd1e97894a9840549127f1ac0a.tar.gz mruby-d26f03b44640dbcd1e97894a9840549127f1ac0a.zip | |
Merge pull request #4358 from shuujii/use-mrb_proc_arity-instead-of-Proc-arity-call-in-Method-arity
Use `mrb_proc_arity` instead of `Proc#arity` call in `Method#arity`
Diffstat (limited to 'mrbgems/mruby-method')
| -rw-r--r-- | mrbgems/mruby-method/src/method.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/mrbgems/mruby-method/src/method.c b/mrbgems/mruby-method/src/method.c index fa8985694..9f1134227 100644 --- a/mrbgems/mruby-method/src/method.c +++ b/mrbgems/mruby-method/src/method.c @@ -212,19 +212,8 @@ static mrb_value method_arity(mrb_state *mrb, mrb_value self) { mrb_value proc = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "proc")); - struct RProc *rproc; - struct RClass *orig; - mrb_value ret; - - if (mrb_nil_p(proc)) - return mrb_fixnum_value(-1); - - rproc = mrb_proc_ptr(proc); - orig = rproc->c; - rproc->c = mrb->proc_class; - ret = mrb_funcall(mrb, proc, "arity", 0); - rproc->c = orig; - return ret; + mrb_int arity = mrb_nil_p(proc) ? -1 : mrb_proc_arity(mrb_proc_ptr(proc)); + return mrb_fixnum_value(arity); } static mrb_value |
