* array.c: revert modify check during iteration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9681d8791b
commit
11674f4a3e
@ -14,11 +14,6 @@ Wed Oct 11 15:03:55 2006 Akinori MUSHA <knu@iDaemons.org>
|
|||||||
recursive calls, but call initialize() when reset() is not
|
recursive calls, but call initialize() when reset() is not
|
||||||
defined in a subclass.
|
defined in a subclass.
|
||||||
|
|
||||||
Wed Oct 11 14:58:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|
||||||
|
|
||||||
* array.c (rb_ary_each): prohibit array modification during each
|
|
||||||
iteration. [ruby-core:09104]
|
|
||||||
|
|
||||||
Wed Oct 11 14:56:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Wed Oct 11 14:56:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* ext/digest/sha1/sha1ossl.h: libssl 0.9.8c-3 defines no
|
* ext/digest/sha1/sha1ossl.h: libssl 0.9.8c-3 defines no
|
||||||
|
34
array.c
34
array.c
@ -1227,24 +1227,6 @@ rb_ary_insert(int argc, VALUE *argv, VALUE ary)
|
|||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
|
||||||
each_internal(VALUE ary)
|
|
||||||
{
|
|
||||||
long i;
|
|
||||||
|
|
||||||
for (i=0; i<RARRAY_LEN(ary); i++) {
|
|
||||||
rb_yield(RARRAY_PTR(ary)[i]);
|
|
||||||
}
|
|
||||||
return ary;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
iter_unlock(VALUE ary)
|
|
||||||
{
|
|
||||||
FL_UNSET(ary, ARY_TMPLOCK);
|
|
||||||
return ary;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* array.each {|item| block } -> array
|
* array.each {|item| block } -> array
|
||||||
@ -1263,9 +1245,12 @@ iter_unlock(VALUE ary)
|
|||||||
VALUE
|
VALUE
|
||||||
rb_ary_each(VALUE ary)
|
rb_ary_each(VALUE ary)
|
||||||
{
|
{
|
||||||
|
long i;
|
||||||
|
|
||||||
RETURN_ENUMERATOR(ary, 0, 0);
|
RETURN_ENUMERATOR(ary, 0, 0);
|
||||||
FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during each */
|
for (i=0; i<RARRAY_LEN(ary); i++) {
|
||||||
rb_ensure(each_internal, ary, iter_unlock, ary);
|
rb_yield(RARRAY_PTR(ary)[i]);
|
||||||
|
}
|
||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1638,6 +1623,13 @@ sort_internal(VALUE ary)
|
|||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
sort_unlock(VALUE ary)
|
||||||
|
{
|
||||||
|
FL_UNSET(ary, ARY_TMPLOCK);
|
||||||
|
return ary;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* array.sort! -> array
|
* array.sort! -> array
|
||||||
@ -1660,7 +1652,7 @@ rb_ary_sort_bang(VALUE ary)
|
|||||||
rb_ary_modify(ary);
|
rb_ary_modify(ary);
|
||||||
if (RARRAY_LEN(ary) > 1) {
|
if (RARRAY_LEN(ary) > 1) {
|
||||||
FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
|
FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
|
||||||
rb_ensure(sort_internal, ary, iter_unlock, ary);
|
rb_ensure(sort_internal, ary, sort_unlock, ary);
|
||||||
}
|
}
|
||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user