Skip to content

Commit

Permalink
Do not funcall() Exception#set_backtrace from runtime.
Browse files Browse the repository at this point in the history
This change reduce flexibility but makes mruby simpler and faster.
  • Loading branch information
matz committed Feb 15, 2017
1 parent 8efa7b0 commit 1e57fef
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,9 @@ exc_get_backtrace(mrb_state *mrb, mrb_value exc)
return backtrace;
}

static mrb_value
exc_set_backtrace(mrb_state *mrb, mrb_value exc)
static void
set_backtrace(mrb_state *mrb, mrb_value exc, mrb_value backtrace)
{
mrb_value backtrace;

mrb_get_args(mrb, "o", &backtrace);
if (!mrb_array_p(backtrace)) {
type_err:
mrb_raise(mrb, E_TYPE_ERROR, "backtrace must be Array of String");
Expand All @@ -222,7 +219,15 @@ exc_set_backtrace(mrb_state *mrb, mrb_value exc)
}
}
mrb_iv_set(mrb, exc, mrb_intern_lit(mrb, "backtrace"), backtrace);
}

static mrb_value
exc_set_backtrace(mrb_state *mrb, mrb_value exc)
{
mrb_value backtrace;

mrb_get_args(mrb, "o", &backtrace);
set_backtrace(mrb, exc, backtrace);
return backtrace;
}

Expand Down Expand Up @@ -253,12 +258,6 @@ exc_debug_info(mrb_state *mrb, struct RObject *exc)
}
}

static void
set_backtrace(mrb_state *mrb, mrb_value info, mrb_value bt)
{
mrb_funcall(mrb, info, "set_backtrace", 1, bt);
}

static mrb_bool
have_backtrace(mrb_state *mrb, struct RObject *exc)
{
Expand Down

0 comments on commit 1e57fef

Please sign in to comment.