1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* enum.c (enum_take): allocate buffer array before iteration, as well

as enum_first did.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-03-16 08:33:10 +00:00
parent a920c29c16
commit 19451891d8
2 changed files with 5 additions and 2 deletions

View file

@ -1,4 +1,7 @@
Fri Mar 16 15:02:35 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
Fri Mar 16 17:33:08 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (enum_take): allocate buffer array before iteration, as well
as enum_first did.
* enum.c (enum_first): remove duplication.

2
enum.c
View file

@ -2050,7 +2050,7 @@ enum_take(VALUE obj, VALUE n)
}
if (len == 0) return rb_ary_new2(0);
result = rb_ary_new();
result = rb_ary_new2(len);
memo = NEW_MEMO(result, 0, len);
rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)memo);
return result;