summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-15 15:54:48 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-15 15:54:48 (GMT)
commitbeeaef3d328096fc4414bcc96fe23ba98250f6e1 (patch)
treea74ae13d67731146e88a2267511b9bd84b7d6158 /proc.c
parent14b8530454b1db7707c9475d027c26858eac817c (diff)
proc.c: refine ifunc checks
* proc.c (IS_METHOD_PROC_IFUNC): separate from IS_METHOD_PROC_ISEQ for vm_ifunc. * proc.c (rb_proc_get_iseq): use RUBY_VM_IFUNC_P to see if iseq is an ifunc. * proc.c (rb_proc_get_iseq, proc_binding): reduce redundant checsk by IS_METHOD_PROC_IFUNC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/proc.c b/proc.c
index eae5e74..03b2520 100644
--- a/proc.c
+++ b/proc.c
@@ -40,7 +40,10 @@ static int method_min_max_arity(VALUE, int *max);
/* Proc */
-#define IS_METHOD_PROC_ISEQ(iseq) (RUBY_VM_IFUNC_P(iseq) && ((struct vm_ifunc *)(iseq))->func == bmcall)
+#define IS_METHOD_PROC_IFUNC(ifunc) ((ifunc)->func == bmcall)
+#define IS_METHOD_PROC_ISEQ(iseq) \
+ (RUBY_VM_IFUNC_P(iseq) && \
+ IS_METHOD_PROC_IFUNC((struct vm_ifunc *)(iseq)))
static void
proc_mark(void *ptr)
@@ -952,10 +955,10 @@ rb_proc_get_iseq(VALUE self, int *is_proc)
GetProcPtr(self, proc);
iseq = proc->block.iseq;
if (is_proc) *is_proc = !proc->is_lambda;
- if (!RUBY_VM_NORMAL_ISEQ_P(iseq)) {
+ if (RUBY_VM_IFUNC_P(iseq)) {
const struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq;
iseq = 0;
- if (IS_METHOD_PROC_ISEQ(ifunc)) {
+ if (IS_METHOD_PROC_IFUNC(ifunc)) {
/* method(:foo).to_proc */
iseq = rb_method_iseq((VALUE)ifunc->data);
if (is_proc) *is_proc = 0;
@@ -2607,8 +2610,9 @@ proc_binding(VALUE self)
envval = rb_vm_proc_envval(proc);
iseq = proc->block.iseq;
if (RUBY_VM_IFUNC_P(iseq)) {
- if (IS_METHOD_PROC_ISEQ(iseq)) {
- VALUE method = (VALUE)((struct vm_ifunc *)iseq)->data;
+ struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq;
+ if (IS_METHOD_PROC_IFUNC(ifunc)) {
+ VALUE method = (VALUE)ifunc->data;
envval = env_clone(envval, method_receiver(method), method_cref(method));
}
else {
@@ -2620,9 +2624,10 @@ proc_binding(VALUE self)
GetBindingPtr(bindval, bind);
bind->env = envval;
- if (!RUBY_VM_NORMAL_ISEQ_P(iseq)) {
- if (IS_METHOD_PROC_ISEQ(iseq)) {
- VALUE method = (VALUE)((struct vm_ifunc *)iseq)->data;
+ if (RUBY_VM_IFUNC_P(iseq)) {
+ struct vm_ifunc *ifunc = (struct vm_ifunc *)iseq;
+ if (IS_METHOD_PROC_IFUNC(ifunc)) {
+ VALUE method = (VALUE)ifunc->data;
iseq = rb_method_iseq(method);
}
else {