* array.c (rb_ary_cat): new function to concat objects into array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
729e66b3c1
commit
e78ff08968
@ -1,3 +1,7 @@
|
|||||||
|
Fri Mar 9 00:25:02 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* array.c (rb_ary_cat): new function to concat objects into array.
|
||||||
|
|
||||||
Thu Mar 8 16:44:02 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Mar 8 16:44:02 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* .gdbinit (rb_numtable_entry): update for recent refactoring of
|
* .gdbinit (rb_numtable_entry): update for recent refactoring of
|
||||||
|
@ -284,6 +284,9 @@ listed below:
|
|||||||
rb_ary_shift(VALUE ary)
|
rb_ary_shift(VALUE ary)
|
||||||
rb_ary_unshift(VALUE ary, VALUE val)
|
rb_ary_unshift(VALUE ary, VALUE val)
|
||||||
|
|
||||||
|
rb_ary_cat(VALUE ary, const VALUE *ptr, long len)
|
||||||
|
|
||||||
|
Appends len elements of objects from ptr to the array.
|
||||||
|
|
||||||
2. Extending Ruby with C
|
2. Extending Ruby with C
|
||||||
|
|
||||||
|
@ -312,6 +312,10 @@ Rubyが用意している関数を用いてください.
|
|||||||
rb_ary_shift(VALUE ary)
|
rb_ary_shift(VALUE ary)
|
||||||
rb_ary_unshift(VALUE ary, VALUE val)
|
rb_ary_unshift(VALUE ary, VALUE val)
|
||||||
|
|
||||||
|
rb_ary_cat(VALUE ary, const VALUE *ptr, long len)
|
||||||
|
|
||||||
|
配列aryにptrからlen個のオブジェクトを追加する.
|
||||||
|
|
||||||
2.Rubyの機能を使う
|
2.Rubyの機能を使う
|
||||||
|
|
||||||
原理的にRubyで書けることはCでも書けます.RubyそのものがCで記
|
原理的にRubyで書けることはCでも書けます.RubyそのものがCで記
|
||||||
|
19
array.c
19
array.c
@ -755,6 +755,19 @@ rb_ary_push_1(VALUE ary, VALUE item)
|
|||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_ary_cat(VALUE ary, const VALUE *ptr, long len)
|
||||||
|
{
|
||||||
|
long oldlen;
|
||||||
|
|
||||||
|
rb_ary_modify(ary);
|
||||||
|
oldlen = RARRAY_LEN(ary);
|
||||||
|
ary_resize_capa(ary, oldlen + len);
|
||||||
|
MEMCPY(RARRAY_PTR(ary) + oldlen, ptr, VALUE, len);
|
||||||
|
ARY_SET_LEN(ary, oldlen + len);
|
||||||
|
return ary;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* ary.push(obj, ... ) -> ary
|
* ary.push(obj, ... ) -> ary
|
||||||
@ -771,11 +784,7 @@ rb_ary_push_1(VALUE ary, VALUE item)
|
|||||||
static VALUE
|
static VALUE
|
||||||
rb_ary_push_m(int argc, VALUE *argv, VALUE ary)
|
rb_ary_push_m(int argc, VALUE *argv, VALUE ary)
|
||||||
{
|
{
|
||||||
rb_ary_modify(ary);
|
return rb_ary_cat(ary, argv, argc);
|
||||||
while (argc--) {
|
|
||||||
rb_ary_push_1(ary, *argv++);
|
|
||||||
}
|
|
||||||
return ary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -42,6 +42,7 @@ struct vtm; /* defined by timev.h */
|
|||||||
/* array.c */
|
/* array.c */
|
||||||
VALUE rb_ary_last(int, VALUE *, VALUE);
|
VALUE rb_ary_last(int, VALUE *, VALUE);
|
||||||
void rb_ary_set_len(VALUE, long);
|
void rb_ary_set_len(VALUE, long);
|
||||||
|
VALUE rb_ary_cat(VALUE, const VALUE *, long);
|
||||||
|
|
||||||
/* bignum.c */
|
/* bignum.c */
|
||||||
VALUE rb_big_fdiv(VALUE x, VALUE y);
|
VALUE rb_big_fdiv(VALUE x, VALUE y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user