[macruby-changes] [742] MacRuby/trunk/set.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 14 04:54:43 PST 2008


Revision: 742
          http://trac.macosforge.org/projects/ruby/changeset/742
Author:   ben at tanjero.com
Date:     2008-11-14 04:54:43 -0800 (Fri, 14 Nov 2008)
Log Message:
-----------
Fixed Set#merge and Set#union so that they work =)

Modified Paths:
--------------
    MacRuby/trunk/set.c

Modified: MacRuby/trunk/set.c
===================================================================
--- MacRuby/trunk/set.c	2008-11-14 12:54:38 UTC (rev 741)
+++ MacRuby/trunk/set.c	2008-11-14 12:54:43 UTC (rev 742)
@@ -119,17 +119,16 @@
 static void
 rb_set_union_callback(const void *value, void *context)
 {
-    CFMutableSetRef *sets = context;
-    if (!CFSetContainsValue(sets[0], RB2OC(value)))
-	CFSetAddValue(sets[1], RB2OC(value));
+    CFMutableSetRef set = context;
+    if (!CFSetContainsValue(set, RB2OC(value)))
+	CFSetAddValue(set, RB2OC(value));
 }
 
 static VALUE
 rb_set_union(VALUE set, VALUE other)
 {
-    VALUE new_set = rb_set_new();
-    CFMutableSetRef sets[2] = { (CFMutableSetRef)other, (CFMutableSetRef)new_set };
-    CFSetApplyFunction((CFMutableSetRef)set, rb_set_union_callback, sets);
+    VALUE new_set = rb_set_dup(set);
+    CFSetApplyFunction((CFMutableSetRef)other, rb_set_union_callback, (void *)new_set);
 
     return new_set;
 }
@@ -139,8 +138,7 @@
 {
     rb_set_modify_check(set);
 
-    CFMutableSetRef sets[2] = { (CFMutableSetRef)other, (CFMutableSetRef)set };
-    CFSetApplyFunction((CFMutableSetRef)set, rb_set_union_callback, sets);
+    CFSetApplyFunction((CFMutableSetRef)other, rb_set_union_callback, (void *)set);
 
     return set;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081114/9c07f092/attachment.html>


More information about the macruby-changes mailing list