mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
proc.c: trivial optimization
* proc.c (rb_proc_arity): reduce repeated GetProcPtr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
55ce57d8cc
commit
598fd0cd94
1 changed files with 3 additions and 4 deletions
7
proc.c
7
proc.c
|
@ -963,18 +963,17 @@ static int
|
|||
rb_proc_min_max_arity(VALUE self, int *max)
|
||||
{
|
||||
rb_proc_t *proc;
|
||||
const struct rb_block *block;
|
||||
GetProcPtr(self, proc);
|
||||
block = &proc->block;
|
||||
return rb_block_min_max_arity(block, max);
|
||||
return rb_block_min_max_arity(&proc->block, max);
|
||||
}
|
||||
|
||||
int
|
||||
rb_proc_arity(VALUE self)
|
||||
{
|
||||
rb_proc_t *proc;
|
||||
int max, min = rb_proc_min_max_arity(self, &max);
|
||||
int max, min;
|
||||
GetProcPtr(self, proc);
|
||||
min = rb_block_min_max_arity(&proc->block, &max);
|
||||
return (proc->is_lambda ? min == max : max != UNLIMITED_ARGUMENTS) ? min : -min-1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue