* enum.c (enum_to_a): Use size to set array capa when possible.
the patch is from HonoreDB <aweiner at mdsol.com>. [fix GH-444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2ce35ac863
commit
d908180164
@ -1,3 +1,9 @@
|
|||||||
|
Sun May 10 11:23:03 2015 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
|
* enum.c (enum_to_a): Use size to set array capa when possible.
|
||||||
|
the patch is from HonoreDB <aweiner at mdsol.com>.
|
||||||
|
[fix GH-444]
|
||||||
|
|
||||||
Sat May 9 06:48:36 2015 Eric Wong <e@80x24.org>
|
Sat May 9 06:48:36 2015 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
* ext/socket/ancdata.c (bsock_recvmsg_internal): GC guard
|
* ext/socket/ancdata.c (bsock_recvmsg_internal): GC guard
|
||||||
|
9
enum.c
9
enum.c
@ -515,7 +515,14 @@ enum_flat_map(VALUE obj)
|
|||||||
static VALUE
|
static VALUE
|
||||||
enum_to_a(int argc, VALUE *argv, VALUE obj)
|
enum_to_a(int argc, VALUE *argv, VALUE obj)
|
||||||
{
|
{
|
||||||
VALUE ary = rb_ary_new();
|
VALUE ary, size = rb_check_funcall(obj, id_size, 0, 0);
|
||||||
|
|
||||||
|
if (NIL_P(size) || size == Qundef) {
|
||||||
|
ary = rb_ary_new();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ary = rb_ary_new_capa(NUM2LONG(size));
|
||||||
|
}
|
||||||
|
|
||||||
rb_block_call(obj, id_each, argc, argv, collect_all, ary);
|
rb_block_call(obj, id_each, argc, argv, collect_all, ary);
|
||||||
OBJ_INFECT(ary, obj);
|
OBJ_INFECT(ary, obj);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user