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
0f2b6964
Commit
0f2b6964
authored
Jun 21, 2012
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #302 from monaka/pr-remove-strlen-in-array
Remove strlen in array
parents
178a1a63
0c5b704d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
src/array.c
src/array.c
+6
-6
test/t/array.rb
test/t/array.rb
+8
-0
No files found.
src/array.c
View file @
0f2b6964
...
...
@@ -880,9 +880,9 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
{
int
i
;
mrb_value
s
,
arystr
;
char
*
head
=
"["
;
char
*
sep
=
", "
;
char
*
tail
=
"]"
;
char
head
[]
=
{
'['
}
;
char
sep
[]
=
{
','
,
' '
}
;
char
tail
[]
=
{
']'
}
;
/* check recursive */
for
(
i
=
0
;
i
<
RARRAY_LEN
(
list
);
i
++
)
{
...
...
@@ -894,13 +894,13 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
mrb_ary_push
(
mrb
,
list
,
ary
);
arystr
=
mrb_str_buf_new
(
mrb
,
64
);
mrb_str_buf_cat
(
mrb
,
arystr
,
head
,
s
trlen
(
head
));
mrb_str_buf_cat
(
mrb
,
arystr
,
head
,
s
izeof
(
head
));
for
(
i
=
0
;
i
<
RARRAY_LEN
(
ary
);
i
++
)
{
int
ai
=
mrb_gc_arena_save
(
mrb
);
if
(
i
>
0
)
{
mrb_str_buf_cat
(
mrb
,
arystr
,
sep
,
s
trlen
(
sep
));
mrb_str_buf_cat
(
mrb
,
arystr
,
sep
,
s
izeof
(
sep
));
}
if
(
mrb_type
(
RARRAY_PTR
(
ary
)[
i
])
==
MRB_TT_ARRAY
)
{
s
=
inspect_ary
(
mrb
,
RARRAY_PTR
(
ary
)[
i
],
list
);
...
...
@@ -911,7 +911,7 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
mrb_gc_arena_restore
(
mrb
,
ai
);
}
mrb_str_buf_cat
(
mrb
,
arystr
,
tail
,
s
trlen
(
tail
));
mrb_str_buf_cat
(
mrb
,
arystr
,
tail
,
s
izeof
(
tail
));
mrb_ary_pop
(
mrb
,
list
);
return
arystr
;
...
...
test/t/array.rb
View file @
0f2b6964
...
...
@@ -234,4 +234,12 @@ assert('Array#unshift', '15.2.12.5.30') do
a
==
[
1
,
2
,
3
]
and
b
==
[
1
,
2
,
3
]
end
assert
(
'Array#to_s'
,
'15.2.12.5.31'
)
do
a
=
[
2
,
3
,
4
,
5
]
r1
=
a
.
to_s
r2
=
a
.
inspect
r1
==
r2
and
r1
==
"[2, 3, 4, 5]"
end
# Not ISO specified
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