Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
c2b37e76
Unverified
Commit
c2b37e76
authored
Jun 22, 2020
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip `mrb_get_args()` in `mrb_ary_{aget,aset}` unless necessary.
Use simpler `mrb_get_argc()` and `mrb_get_arg1()` instead.
parent
d40b922c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
src/array.c
src/array.c
+10
-3
No files found.
src/array.c
View file @
c2b37e76
...
...
@@ -866,10 +866,12 @@ static mrb_value
mrb_ary_aget
(
mrb_state
*
mrb
,
mrb_value
self
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
self
);
mrb_int
i
,
len
,
alen
;
mrb_int
i
;
mrb_int
len
,
alen
;
mrb_value
index
;
if
(
mrb_get_args
(
mrb
,
"o|i"
,
&
index
,
&
len
)
==
1
)
{
if
(
mrb_get_argc
(
mrb
)
==
1
)
{
index
=
mrb_get_arg1
(
mrb
);
switch
(
mrb_type
(
index
))
{
/* a[n..m] */
case
MRB_TT_RANGE
:
...
...
@@ -886,6 +888,7 @@ mrb_ary_aget(mrb_state *mrb, mrb_value self)
}
}
mrb_get_args
(
mrb
,
"oi"
,
&
index
,
&
len
);
i
=
aget_index
(
mrb
,
index
);
alen
=
ARY_LEN
(
a
);
if
(
i
<
0
)
i
+=
alen
;
...
...
@@ -939,7 +942,10 @@ mrb_ary_aset(mrb_state *mrb, mrb_value self)
mrb_int
i
,
len
;
mrb_ary_modify
(
mrb
,
mrb_ary_ptr
(
self
));
if
(
mrb_get_args
(
mrb
,
"oo|o"
,
&
v1
,
&
v2
,
&
v3
)
==
2
)
{
if
(
mrb_get_argc
(
mrb
)
==
2
)
{
mrb_value
*
vs
=
mrb_get_argv
(
mrb
);
v1
=
vs
[
0
];
v2
=
vs
[
1
];
/* a[n..m] = v */
switch
(
mrb_range_beg_len
(
mrb
,
v1
,
&
i
,
&
len
,
RARRAY_LEN
(
self
),
FALSE
))
{
case
MRB_RANGE_TYPE_MISMATCH
:
...
...
@@ -955,6 +961,7 @@ mrb_ary_aset(mrb_state *mrb, mrb_value self)
return
v2
;
}
mrb_get_args
(
mrb
,
"ooo"
,
&
v1
,
&
v2
,
&
v3
);
/* a[n,m] = v */
mrb_ary_splice
(
mrb
,
self
,
aget_index
(
mrb
,
v1
),
aget_index
(
mrb
,
v2
),
v3
);
return
v3
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment