mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Reuse rb_proc_arity
This commit is contained in:
parent
84f410e5e6
commit
554befbf27
Notes:
git
2022-04-25 06:07:25 +09:00
Merged: https://github.com/ruby/ruby/pull/5823 Merged-By: jeremyevans <code@jeremyevans.net>
1 changed files with 2 additions and 7 deletions
9
proc.c
9
proc.c
|
@ -1208,21 +1208,16 @@ rb_block_arity(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
block_setup(&block, block_handler);
|
block_setup(&block, block_handler);
|
||||||
min = rb_vm_block_min_max_arity(&block, &max);
|
|
||||||
|
|
||||||
switch (vm_block_type(&block)) {
|
switch (vm_block_type(&block)) {
|
||||||
case block_handler_type_symbol:
|
case block_handler_type_symbol:
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case block_handler_type_proc:
|
case block_handler_type_proc:
|
||||||
{
|
return rb_proc_arity(block_handler);
|
||||||
VALUE procval = block_handler;
|
|
||||||
rb_proc_t *proc;
|
|
||||||
GetProcPtr(procval, proc);
|
|
||||||
return (proc->is_lambda ? min == max : max != UNLIMITED_ARGUMENTS) ? min : -min-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
min = rb_vm_block_min_max_arity(&block, &max);
|
||||||
return max != UNLIMITED_ARGUMENTS ? min : -min-1;
|
return max != UNLIMITED_ARGUMENTS ? min : -min-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue