mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/enumerator/enumerator.c (each_cons_i): pass copy of an
internal consequent array. [ruby-talk:118691] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7b45f99288
commit
0b4597eccf
2 changed files with 10 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Nov 2 16:35:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/enumerator/enumerator.c (each_cons_i): pass copy of an
|
||||||
|
internal consequent array. [ruby-talk:118691]
|
||||||
|
|
||||||
Tue Nov 2 14:54:02 2004 NAKAMURA Usaku <usa@ruby-lang.org>
|
Tue Nov 2 14:54:02 2004 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (pipe_open): need to set cmd if argc == 0 (win32).
|
* io.c (pipe_open): need to set cmd if argc == 0 (win32).
|
||||||
|
|
|
@ -87,15 +87,13 @@ each_cons_i(val, memo)
|
||||||
{
|
{
|
||||||
VALUE ary = memo->u1.value;
|
VALUE ary = memo->u1.value;
|
||||||
long size = memo->u3.cnt;
|
long size = memo->u3.cnt;
|
||||||
long len = RARRAY(ary)->len;
|
|
||||||
|
|
||||||
if (len == size) {
|
if (RARRAY(ary)->len == size) {
|
||||||
rb_ary_shift(ary);
|
rb_ary_shift(ary);
|
||||||
|
}
|
||||||
rb_ary_push(ary, val);
|
rb_ary_push(ary, val);
|
||||||
rb_yield(ary);
|
if (RARRAY(ary)->len == size) {
|
||||||
} else {
|
rb_yield(rb_ary_dup(ary));
|
||||||
rb_ary_push(ary, val);
|
|
||||||
if (len + 1 == size) rb_yield(ary);
|
|
||||||
}
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +104,6 @@ enum_each_cons(obj, n)
|
||||||
{
|
{
|
||||||
long size = NUM2LONG(n);
|
long size = NUM2LONG(n);
|
||||||
NODE *memo;
|
NODE *memo;
|
||||||
VALUE ary;
|
|
||||||
|
|
||||||
if (size <= 0) rb_raise(rb_eArgError, "invalid size");
|
if (size <= 0) rb_raise(rb_eArgError, "invalid size");
|
||||||
memo = rb_node_newnode(NODE_MEMO, rb_ary_new2(size), 0, size);
|
memo = rb_node_newnode(NODE_MEMO, rb_ary_new2(size), 0, size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue