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
cc71bd51
Commit
cc71bd51
authored
Jul 13, 2014
by
Tatsuhiko Kubo
Committed by
Yukihiro "Matz" Matsumoto
Dec 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize Proc#parameters
parent
94b73b14
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
mrbgems/mruby-proc-ext/src/proc.c
mrbgems/mruby-proc-ext/src/proc.c
+13
-10
No files found.
mrbgems/mruby-proc-ext/src/proc.c
View file @
cc71bd51
...
@@ -94,20 +94,21 @@ static mrb_value
...
@@ -94,20 +94,21 @@ static mrb_value
mrb_proc_parameters
(
mrb_state
*
mrb
,
mrb_value
self
)
mrb_proc_parameters
(
mrb_state
*
mrb
,
mrb_value
self
)
{
{
struct
parameters_type
{
struct
parameters_type
{
int
size
;
size_t
len
;
const
char
*
name
;
const
char
*
name
;
int
size
;
}
*
p
,
parameters_list
[]
=
{
}
*
p
,
parameters_list
[]
=
{
{
0
,
"req"
},
{
sizeof
(
"req"
)
-
1
,
"req"
,
0
},
{
0
,
"opt"
},
{
sizeof
(
"opt"
)
-
1
,
"opt"
,
0
},
{
0
,
"rest"
},
{
sizeof
(
"rest"
)
-
1
,
"rest"
,
0
},
{
0
,
"req"
},
{
sizeof
(
"req"
)
-
1
,
"req"
,
0
},
{
0
,
"block"
},
{
sizeof
(
"block"
)
-
1
,
"block"
,
0
},
{
0
,
NULL
}
{
0
,
NULL
,
0
}
};
};
const
struct
RProc
*
proc
=
mrb_proc_ptr
(
self
);
const
struct
RProc
*
proc
=
mrb_proc_ptr
(
self
);
const
struct
mrb_irep
*
irep
=
proc
->
body
.
irep
;
const
struct
mrb_irep
*
irep
=
proc
->
body
.
irep
;
mrb_aspec
aspec
;
mrb_aspec
aspec
;
mrb_value
sname
,
parameters
;
mrb_value
parameters
;
int
i
,
j
;
int
i
,
j
;
int
max
=
-
1
;
int
max
=
-
1
;
...
@@ -126,7 +127,9 @@ mrb_proc_parameters(mrb_state *mrb, mrb_value self)
...
@@ -126,7 +127,9 @@ mrb_proc_parameters(mrb_state *mrb, mrb_value self)
}
}
if
(
!
MRB_PROC_STRICT_P
(
proc
))
{
if
(
!
MRB_PROC_STRICT_P
(
proc
))
{
parameters_list
[
0
].
len
=
sizeof
(
"opt"
)
-
1
;
parameters_list
[
0
].
name
=
"opt"
;
parameters_list
[
0
].
name
=
"opt"
;
parameters_list
[
3
].
len
=
sizeof
(
"opt"
)
-
1
;
parameters_list
[
3
].
name
=
"opt"
;
parameters_list
[
3
].
name
=
"opt"
;
}
}
...
@@ -141,8 +144,8 @@ mrb_proc_parameters(mrb_state *mrb, mrb_value self)
...
@@ -141,8 +144,8 @@ mrb_proc_parameters(mrb_state *mrb, mrb_value self)
max
=
irep
->
nlocals
-
1
;
max
=
irep
->
nlocals
-
1
;
for
(
i
=
0
,
p
=
parameters_list
;
p
->
name
;
p
++
)
{
for
(
i
=
0
,
p
=
parameters_list
;
p
->
name
;
p
++
)
{
if
(
p
->
size
<=
0
)
continue
;
mrb_value
sname
=
mrb_symbol_value
(
mrb_intern_static
(
mrb
,
p
->
name
,
p
->
len
))
;
sname
=
mrb_symbol_value
(
mrb_intern_cstr
(
mrb
,
p
->
name
));
for
(
j
=
0
;
j
<
p
->
size
;
i
++
,
j
++
)
{
for
(
j
=
0
;
j
<
p
->
size
;
i
++
,
j
++
)
{
mrb_value
a
;
mrb_value
a
;
...
...
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