summaryrefslogtreecommitdiffhomepage
path: root/src/array.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-08-18 19:29:07 +0900
committerYukihiro Matsumoto <[email protected]>2012-08-18 19:29:07 +0900
commite5dde46c7cbc65e12461a2d67f51cc61470a1902 (patch)
treefa664b9feb7961d5f77354648503a271a219e07b /src/array.c
parentfd086a7d081c19ea1b2db85e0e5c55d0736b8728 (diff)
downloadmruby-e5dde46c7cbc65e12461a2d67f51cc61470a1902.tar.gz
mruby-e5dde46c7cbc65e12461a2d67f51cc61470a1902.zip
reduce mrb_funcall invocations
Diffstat (limited to 'src/array.c')
-rw-r--r--src/array.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/array.c b/src/array.c
index 804c946da..15b6df0f2 100644
--- a/src/array.c
+++ b/src/array.c
@@ -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;
}
}