summaryrefslogtreecommitdiffhomepage
path: root/src/array.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-08-11 12:57:37 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-08-11 12:57:37 +0900
commitef0b239704c2552f19f4e23d6c206884650a77ac (patch)
treedacc7d22899cf699b759a2ce31d897ae6179a3fe /src/array.c
parent67e2dddb8254fbf4a4eb81c1241ec1963bc77627 (diff)
downloadmruby-ef0b239704c2552f19f4e23d6c206884650a77ac.tar.gz
mruby-ef0b239704c2552f19f4e23d6c206884650a77ac.zip
Remove unnecessary inline function `ary_elt`.
And the function does not conform the naming convention anyway.
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 2ef29dcf5..e97aaa1c9 100644
--- a/src/array.c
+++ b/src/array.c
@@ -1074,7 +1074,10 @@ mrb_ary_entry(mrb_value ary, mrb_int offset)
if (offset < 0) {
offset += RARRAY_LEN(ary);
}
- return ary_elt(ary, offset);
+ if (offset < 0 || RARRAY_LEN(ary) <= offset) {
+ return mrb_nil_value();
+ }
+ return RARRAY_PTR(ary)[offset];
}
static mrb_value