mruby-array-ext/array.c (mrb_ary_values_at): avoid mrb_get_args().
authorYukihiro "Matz" Matsumoto <[email protected]>
Thu, 20 Oct 2022 10:07:25 +0000 (20 19:07 +0900)
committerYukihiro "Matz" Matsumoto <[email protected]>
Thu, 20 Oct 2022 10:07:25 +0000 (20 19:07 +0900)
If your function doesn't call VM recursively, you can use mrb_get_argv()
instead of mrb_get_args(mrb, "*", ...).

mrbgems/mruby-array-ext/src/array.c

index d77b316..93c2d33 100644 (file)
@@ -104,10 +104,8 @@ ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n)
 static mrb_value
 mrb_ary_values_at(mrb_state *mrb, mrb_value self)
 {
-  mrb_int argc;
-  const mrb_value *argv;
-
-  mrb_get_args(mrb, "*", &argv, &argc);
+  mrb_int argc = mrb_get_argc(mrb);
+  const mrb_value *argv = mrb_get_argv(mrb);
 
   return mrb_get_values_at(mrb, self, RARRAY_LEN(self), argc, argv, ary_ref);
 }