[macruby-changes] [5196] MacRuby/trunk/array.c
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jan 27 19:29:13 PST 2011
Revision: 5196
http://trac.macosforge.org/projects/ruby/changeset/5196
Author: lsansonetti at apple.com
Date: 2011-01-27 19:29:12 -0800 (Thu, 27 Jan 2011)
Log Message:
-----------
re-fix Array#delete to conform to CRuby behavior (a better fix than r5099)
Revision Links:
--------------
http://trac.macosforge.org/projects/ruby/changeset/5099
Modified Paths:
--------------
MacRuby/trunk/array.c
Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c 2011-01-28 02:59:19 UTC (rev 5195)
+++ MacRuby/trunk/array.c 2011-01-28 03:29:12 UTC (rev 5196)
@@ -1799,7 +1799,7 @@
*/
static bool
-rary_delete_element(VALUE ary, VALUE item, bool use_equal)
+rary_delete_element(VALUE ary, VALUE item, bool use_equal, bool check_modify)
{
VALUE *p = rary_ptr(ary);
VALUE *t = p;
@@ -1808,6 +1808,10 @@
if (use_equal) {
while (t < end) {
if (RTEST(rb_equal_fast(*t, item))) {
+ if (check_modify) {
+ rary_modify(ary);
+ check_modify = false;
+ }
t++;
}
else {
@@ -1820,6 +1824,10 @@
else {
while (t < end) {
if (*t == item) {
+ if (check_modify) {
+ rary_modify(ary);
+ check_modify = false;
+ }
t++;
}
else {
@@ -1842,8 +1850,7 @@
VALUE
rary_delete(VALUE ary, SEL sel, VALUE item)
{
- rary_modify(ary);
- const bool changed = rary_delete_element(ary, item, true);
+ const bool changed = rary_delete_element(ary, item, true, true);
if (!changed) {
if (rb_block_given_p()) {
return rb_yield(item);
@@ -2836,7 +2843,7 @@
rary_compact_bang(VALUE ary, SEL sel)
{
rary_modify(ary);
- return rary_delete_element(ary, Qnil, false) ? ary : Qnil;
+ return rary_delete_element(ary, Qnil, false, false) ? ary : Qnil;
}
/*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110127/835af0b7/attachment.html>
More information about the macruby-changes
mailing list