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
03c2b865
Unverified
Commit
03c2b865
authored
4 years ago
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `mrb_get_argc()` to improve performance.
parent
ea6e1b00
master
removing-y-tab-c
revert-5391-throw
stable
3.1.0-rc
3.0.0
3.0.0-rc
3.0.0-preview
2.1.2
2.1.2-rc2
2.1.2-rc
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
16 deletions
+22
-16
mrbgems/mruby-array-ext/src/array.c
mrbgems/mruby-array-ext/src/array.c
+1
-2
src/string.c
src/string.c
+21
-14
No files found.
mrbgems/mruby-array-ext/src/array.c
View file @
03c2b865
...
...
@@ -138,9 +138,8 @@ mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
mrb_ary_modify
(
mrb
,
a
);
if
(
mrb_get_argc
(
mrb
)
==
1
)
{
mrb_value
index
;
mrb_value
index
=
mrb_get_arg1
(
mrb
)
;
mrb_get_args
(
mrb
,
"o|i"
,
&
index
,
&
len
);
switch
(
mrb_type
(
index
))
{
case
MRB_TT_RANGE
:
if
(
mrb_range_beg_len
(
mrb
,
index
,
&
i
,
&
len
,
ARY_LEN
(
a
),
TRUE
)
==
MRB_RANGE_OK
)
{
...
...
This diff is collapsed.
Click to expand it.
src/string.c
View file @
03c2b865
...
...
@@ -2885,15 +2885,18 @@ mrb_str_setbyte(mrb_state *mrb, mrb_value str)
static
mrb_value
mrb_str_byteslice
(
mrb_state
*
mrb
,
mrb_value
str
)
{
mrb_value
a1
,
a2
;
mrb_value
a1
;
mrb_int
str_len
=
RSTRING_LEN
(
str
),
beg
,
len
;
mrb_bool
empty
=
TRUE
;
if
(
mrb_get_args
(
mrb
,
"o|o"
,
&
a1
,
&
a2
)
==
2
)
{
beg
=
mrb_fixnum
(
mrb_to_int
(
mrb
,
a1
));
len
=
mrb_fixnum
(
mrb_to_int
(
mrb
,
a2
));
}
else
if
(
mrb_range_p
(
a1
))
{
len
=
mrb_get_argc
(
mrb
);
switch
(
len
)
{
case
2
:
mrb_get_args
(
mrb
,
"ii"
,
&
beg
,
&
len
);
break
;
case
1
:
a1
=
mrb_get_arg1
(
mrb
);
if
(
mrb_range_p
(
a1
))
{
if
(
mrb_range_beg_len
(
mrb
,
a1
,
&
beg
,
&
len
,
str_len
,
TRUE
)
!=
MRB_RANGE_OK
)
{
return
mrb_nil_value
();
}
...
...
@@ -2903,7 +2906,11 @@ mrb_str_byteslice(mrb_state *mrb, mrb_value str)
len
=
1
;
empty
=
FALSE
;
}
break
;
default:
mrb_argnum_error
(
mrb
,
len
,
1
,
2
);
break
;
}
if
(
mrb_str_beg_len
(
str_len
,
&
beg
,
&
len
)
&&
(
empty
||
len
!=
0
))
{
return
mrb_str_byte_subseq
(
mrb
,
str
,
beg
,
len
);
}
...
...
This diff is collapsed.
Click to expand it.
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