[macruby-changes] [1774] MacRuby/branches/experimental/array.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Jun 5 22:02:44 PDT 2009


Revision: 1774
          http://trac.macosforge.org/projects/ruby/changeset/1774
Author:   lsansonetti at apple.com
Date:     2009-06-05 22:02:44 -0700 (Fri, 05 Jun 2009)
Log Message:
-----------
Array#unshift: check if the receiver can be modified even if there is nothing to unshift

Modified Paths:
--------------
    MacRuby/branches/experimental/array.c

Modified: MacRuby/branches/experimental/array.c
===================================================================
--- MacRuby/branches/experimental/array.c	2009-06-06 04:59:21 UTC (rev 1773)
+++ MacRuby/branches/experimental/array.c	2009-06-06 05:02:44 UTC (rev 1774)
@@ -603,11 +603,13 @@
 static VALUE
 rb_ary_unshift_m(VALUE ary, SEL sel, int argc, VALUE *argv)
 {
-    int i;
+    rb_ary_modify(ary);
+
     if (argc == 0) {
 	return ary;
     }
-    rb_ary_modify(ary);
+
+    int i;
     for (i = argc - 1; i >= 0; i--) {
 	CFArrayInsertValueAtIndex((CFMutableArrayRef)ary,
 	    0, (const void *)RB2OC(argv[i]));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090605/23dac518/attachment.html>


More information about the macruby-changes mailing list