mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
reduce mrb_funcall invocations
This commit is contained in:
+4
-1
@@ -290,12 +290,15 @@ mrb_ary_cmp(mrb_state *mrb, mrb_value ary1)
|
||||
a1 = RARRAY(ary1); a2 = RARRAY(ary2);
|
||||
if (a1->len == a2->len && a1->ptr == a2->ptr) return mrb_fixnum_value(0);
|
||||
else {
|
||||
mrb_sym cmp = mrb_intern(mrb, "<=>");
|
||||
|
||||
len = RARRAY_LEN(ary1);
|
||||
if (len > RARRAY_LEN(ary2)) {
|
||||
len = RARRAY_LEN(ary2);
|
||||
}
|
||||
for (i=0; i<len; i++) {
|
||||
r = mrb_funcall(mrb, ary_elt(ary1, i), "<=>", 1, ary_elt(ary2, i));
|
||||
mrb_value v = ary_elt(ary2, i);
|
||||
r = mrb_funcall_argv(mrb, ary_elt(ary1, i), cmp, 1, &v);
|
||||
if (mrb_type(r) != MRB_TT_FIXNUM || mrb_fixnum(r) != 0) return r;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -277,7 +277,7 @@ sysexit_status(mrb_state *mrb, mrb_value err)
|
||||
static void
|
||||
set_backtrace(mrb_state *mrb, mrb_value info, mrb_value bt)
|
||||
{
|
||||
mrb_funcall(mrb, info, "set_backtrace", 1, bt);
|
||||
mrb_funcall(mrb, info, "set_backtrace", 1, bt);
|
||||
}
|
||||
|
||||
mrb_value
|
||||
|
||||
@@ -65,8 +65,6 @@ static char * option_to_str(char str[4], int options);
|
||||
mrb_value
|
||||
mrb_reg_s_new_instance(mrb_state *mrb, /*int argc, mrb_value *argv, */mrb_value self)
|
||||
{
|
||||
//obj = mrb_obj_alloc(klass);
|
||||
//mrb_obj_call_init(obj, argc, argv);...mrb_funcall2(obj, idInitialize, argc, argv);
|
||||
mrb_value argv[16];
|
||||
int argc;
|
||||
struct RRegexp *re;
|
||||
@@ -76,7 +74,7 @@ mrb_reg_s_new_instance(mrb_state *mrb, /*int argc, mrb_value *argv, */mrb_value
|
||||
re->ptr = 0;
|
||||
re->src = 0;
|
||||
re->usecnt = 0;
|
||||
return mrb_funcall_argv(mrb, mrb_obj_value(re), mrb_intern(mrb, "initialize"), argc, argv);
|
||||
return mrb_funcall_argv(mrb, mrb_obj_value(re), mrb->init_sym, argc, argv);
|
||||
}
|
||||
|
||||
mrb_value
|
||||
|
||||
@@ -1721,7 +1721,6 @@ mrb_str_match_m(mrb_state *mrb, mrb_value self)
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%d for 1..2)", argc);
|
||||
re = argv[0];
|
||||
argv[0] = self;
|
||||
// result = mrb_funcall2(get_pat(re, 0), mrb_intern("match"), argc, argv);
|
||||
result = mrb_funcall(mrb, get_pat(mrb, re, 0), "match", 1, self);
|
||||
if (!mrb_nil_p(result) && mrb_block_given_p()) {
|
||||
return mrb_yield(mrb, b, result);
|
||||
|
||||
+1
-1
@@ -708,7 +708,7 @@ const_get(mrb_state *mrb, struct RClass *base, mrb_sym sym)
|
||||
while (c) {
|
||||
if (mrb_respond_to(mrb, mrb_obj_value(c), cm)) {
|
||||
mrb_value name = mrb_symbol_value(sym);
|
||||
return mrb_funcall(mrb, mrb_obj_value(c), "const_missing", 1, name);
|
||||
return mrb_funcall_argv(mrb, mrb_obj_value(c), cm, 1, &name);
|
||||
}
|
||||
c = c->super;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user