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

* enum.c (enum_find): catch a value before recycle.

* enum.c (enum_all): ditto.

* enum.c (enum_any): ditto.

* enum.c (enum_min): ditto.

* enum.c (enum_max): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2002-03-18 01:48:56 +00:00
parent cecb9cae01
commit e3235029ad
2 changed files with 28 additions and 7 deletions

View file

@ -1,3 +1,15 @@
Mon Mar 18 10:31:20 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* enum.c (enum_find): catch a value before recycle.
* enum.c (enum_all): ditto.
* enum.c (enum_any): ditto.
* enum.c (enum_min): ditto.
* enum.c (enum_max): ditto.
Sun Mar 17 20:08:04 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* ext/iconv/depend: added.

23
enum.c
View file

@ -85,8 +85,9 @@ enum_find(argc, argv, obj)
rb_scan_args(argc, argv, "01", &if_none);
rb_iterate(rb_each, obj, find_i, (VALUE)memo);
if (memo->u2.value) {
VALUE result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return memo->u1.value;
return result;
}
rb_gc_force_recycle((VALUE)memo);
if (!NIL_P(if_none)) {
@ -188,8 +189,9 @@ inject_i(i, memo)
memo->u2.value = Qfalse;
memo->u1.value = i;
}
else
else {
memo->u1.value = rb_yield(rb_assoc_new(memo->u1.value, i));
}
return Qnil;
}
@ -278,12 +280,14 @@ static VALUE
enum_all(obj)
VALUE obj;
{
VALUE result;
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
memo->u1.value = Qtrue;
rb_iterate(rb_each, obj, all_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return memo->u1.value;
return result;
}
static VALUE
@ -302,12 +306,14 @@ static VALUE
enum_any(obj)
VALUE obj;
{
VALUE result;
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
memo->u1.value = Qfalse;
rb_iterate(rb_each, obj, any_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return memo->u1.value;
return result;
}
static VALUE
@ -348,11 +354,13 @@ static VALUE
enum_min(obj)
VALUE obj;
{
VALUE result;
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
rb_iterate(rb_each, obj, rb_block_given_p()?min_ii:min_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return memo->u1.value;
return result;
}
static VALUE
@ -393,11 +401,13 @@ static VALUE
enum_max(obj)
VALUE obj;
{
VALUE result;
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
rb_iterate(rb_each, obj, rb_block_given_p()?max_ii:max_i, (VALUE)memo);
result = memo->u1.value;
rb_gc_force_recycle((VALUE)memo);
return memo->u1.value;
return result;
}
static VALUE
@ -417,7 +427,6 @@ enum_member(obj, val)
VALUE obj, val;
{
VALUE result;
NODE *memo = rb_node_newnode(NODE_MEMO, val, Qfalse, 0);
rb_iterate(rb_each, obj, member_i, (VALUE)memo);