diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-12-19 19:05:27 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-12-19 19:05:27 +0900 |
| commit | 358dd61107b64ca65cb6febb89f818388f62878e (patch) | |
| tree | 5363d21a27f77feec6bfacda863911c545a1b6e0 | |
| parent | 5014bfb50d911a9ad9b8069ed49db7666b101796 (diff) | |
| download | mruby-358dd61107b64ca65cb6febb89f818388f62878e.tar.gz mruby-358dd61107b64ca65cb6febb89f818388f62878e.zip | |
block_given? should return correct value when called in blocks; close #2678
avoid a loop to find parent's callinfo using mrb->c->cibase[env->cioff]
| -rw-r--r-- | src/kernel.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/kernel.c b/src/kernel.c index b6abfd265..485485da5 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -192,12 +192,8 @@ mrb_f_block_given_p_m(mrb_state *mrb, mrb_value self) /* top-level does not have block slot (alway false) */ if (sp == mrb->c->stbase) return mrb_false_value(); - while (mrb->c->cibase < ci) { - if (ci->stackent == sp) { - break; - } - ci--; - } + ci = mrb->c->cibase + ci->proc->env->cioff; + bp = ci[1].stackent + 1; } if (ci->argc > 0) { bp += ci->argc; |
