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
ebbc7d0e
Commit
ebbc7d0e
authored
Jun 03, 2015
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2822 from cremno/directly-call-ary_new_capa
directly call ary_new_capa()
parents
059da2ad
599d141c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
18 deletions
+8
-18
src/array.c
src/array.c
+8
-18
No files found.
src/array.c
View file @
ebbc7d0e
...
...
@@ -88,15 +88,12 @@ array_copy(mrb_value *dst, const mrb_value *src, mrb_int size)
MRB_API
mrb_value
mrb_ary_new_from_values
(
mrb_state
*
mrb
,
mrb_int
size
,
const
mrb_value
*
vals
)
{
mrb_value
ary
;
struct
RArray
*
a
;
struct
RArray
*
a
=
ary_new_capa
(
mrb
,
size
);
ary
=
mrb_ary_new_capa
(
mrb
,
size
);
a
=
mrb_ary_ptr
(
ary
);
array_copy
(
a
->
ptr
,
vals
,
size
);
a
->
len
=
size
;
return
ary
;
return
mrb_obj_value
(
a
)
;
}
MRB_API
mrb_value
...
...
@@ -293,7 +290,6 @@ mrb_ary_plus(mrb_state *mrb, mrb_value self)
{
struct
RArray
*
a1
=
mrb_ary_ptr
(
self
);
struct
RArray
*
a2
;
mrb_value
ary
;
mrb_value
*
ptr
;
mrb_int
blen
;
...
...
@@ -301,13 +297,12 @@ mrb_ary_plus(mrb_state *mrb, mrb_value self)
if
(
ARY_MAX_SIZE
-
blen
<
a1
->
len
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
}
ary
=
mrb_ary_new_capa
(
mrb
,
a1
->
len
+
blen
);
a2
=
mrb_ary_ptr
(
ary
);
a2
=
ary_new_capa
(
mrb
,
a1
->
len
+
blen
);
array_copy
(
a2
->
ptr
,
a1
->
ptr
,
a1
->
len
);
array_copy
(
a2
->
ptr
+
a1
->
len
,
ptr
,
blen
);
a2
->
len
=
a1
->
len
+
blen
;
return
ary
;
return
mrb_obj_value
(
a2
)
;
}
static
void
...
...
@@ -345,7 +340,6 @@ mrb_ary_times(mrb_state *mrb, mrb_value self)
{
struct
RArray
*
a1
=
mrb_ary_ptr
(
self
);
struct
RArray
*
a2
;
mrb_value
ary
;
mrb_value
*
ptr
;
mrb_int
times
;
...
...
@@ -357,8 +351,7 @@ mrb_ary_times(mrb_state *mrb, mrb_value self)
if
(
ARY_MAX_SIZE
/
times
<
a1
->
len
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
}
ary
=
mrb_ary_new_capa
(
mrb
,
a1
->
len
*
times
);
a2
=
mrb_ary_ptr
(
ary
);
a2
=
ary_new_capa
(
mrb
,
a1
->
len
*
times
);
ptr
=
a2
->
ptr
;
while
(
times
--
)
{
array_copy
(
ptr
,
a1
->
ptr
,
a1
->
len
);
...
...
@@ -366,7 +359,7 @@ mrb_ary_times(mrb_state *mrb, mrb_value self)
a2
->
len
+=
a1
->
len
;
}
return
ary
;
return
mrb_obj_value
(
a2
)
;
}
static
mrb_value
...
...
@@ -393,11 +386,8 @@ mrb_ary_reverse_bang(mrb_state *mrb, mrb_value self)
static
mrb_value
mrb_ary_reverse
(
mrb_state
*
mrb
,
mrb_value
self
)
{
struct
RArray
*
a
=
mrb_ary_ptr
(
self
),
*
b
;
mrb_value
ary
;
struct
RArray
*
a
=
mrb_ary_ptr
(
self
),
*
b
=
ary_new_capa
(
mrb
,
a
->
len
);
ary
=
mrb_ary_new_capa
(
mrb
,
a
->
len
);
b
=
mrb_ary_ptr
(
ary
);
if
(
a
->
len
>
0
)
{
mrb_value
*
p1
,
*
p2
,
*
e
;
...
...
@@ -409,7 +399,7 @@ mrb_ary_reverse(mrb_state *mrb, mrb_value self)
}
b
->
len
=
a
->
len
;
}
return
ary
;
return
mrb_obj_value
(
b
)
;
}
MRB_API
void
...
...
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