mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
array.c (mrb_ary_last): avoid mrb_get_args()
This commit is contained in:
+3
-4
@@ -1114,14 +1114,13 @@ static mrb_value
|
||||
mrb_ary_last(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
struct RArray *a = mrb_ary_ptr(self);
|
||||
mrb_int n, size, alen;
|
||||
mrb_int alen = ARY_LEN(a);
|
||||
|
||||
n = mrb_get_args(mrb, "|i", &size);
|
||||
alen = ARY_LEN(a);
|
||||
if (n == 0) {
|
||||
if (mrb_get_argc(mrb) == 0) {
|
||||
return (alen > 0) ? ARY_PTR(a)[alen - 1]: mrb_nil_value();
|
||||
}
|
||||
|
||||
mrb_int size = mrb_integer(mrb_get_arg1(mrb));
|
||||
if (size < 0) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "negative array size");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user