diff options
| author | Yukihiro Matz Matsumoto <[email protected]> | 2013-03-08 05:18:33 +0900 |
|---|---|---|
| committer | Yukihiro Matz Matsumoto <[email protected]> | 2013-03-08 05:18:33 +0900 |
| commit | cdd41a33de55369bd89bdf916d6ab419bd93c2b5 (patch) | |
| tree | 2c42b634d9d5dffda744930e7da19f4ff0817e3f /src/array.c | |
| parent | 7d47096434994d9eb9712546879e3b52b04d3443 (diff) | |
| download | mruby-cdd41a33de55369bd89bdf916d6ab419bd93c2b5.tar.gz mruby-cdd41a33de55369bd89bdf916d6ab419bd93c2b5.zip | |
unify mrb_ary_new{,_elts,_from_values}; mrb_ary_from_values() is a winner
Diffstat (limited to 'src/array.c')
| -rw-r--r-- | src/array.c | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/src/array.c b/src/array.c index b8cd436f0..97f76f8da 100644 --- a/src/array.c +++ b/src/array.c @@ -89,21 +89,6 @@ array_copy(mrb_value *dst, const mrb_value *src, size_t size) } } - -mrb_value -mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, mrb_value *vals) -{ - mrb_value ary; - struct RArray *a; - - ary = mrb_ary_new_capa(mrb, size); - a = mrb_ary_ptr(ary); - array_copy(a->ptr, vals, size); - a->len = size; - - return ary; -} - mrb_value mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr) { @@ -433,25 +418,19 @@ mrb_ary_reverse(mrb_state *mrb, mrb_value self) } mrb_value -mrb_ary_new4(mrb_state *mrb, mrb_int n, const mrb_value *elts) +mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals) { mrb_value ary; + struct RArray *a; - ary = mrb_ary_new_capa(mrb, n); - if (n > 0 && elts) { - array_copy(RARRAY_PTR(ary), elts, n); - RARRAY_LEN(ary) = n; - } + ary = mrb_ary_new_capa(mrb, size); + a = mrb_ary_ptr(ary); + array_copy(a->ptr, vals, size); + a->len = size; return ary; } -mrb_value -mrb_ary_new_elts(mrb_state *mrb, mrb_int n, const mrb_value *elts) -{ - return mrb_ary_new4(mrb, n, elts); -} - void mrb_ary_push(mrb_state *mrb, mrb_value ary, mrb_value elem) /* mrb_ary_push */ { |
