[macruby-changes] [2974] MacRuby/trunk/dispatcher.cpp

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 6 19:11:14 PST 2009


Revision: 2974
          http://trac.macosforge.org/projects/ruby/changeset/2974
Author:   lsansonetti at apple.com
Date:     2009-11-06 19:11:14 -0800 (Fri, 06 Nov 2009)
Log Message:
-----------
disable #[], #[]= and #<< optimizations for subclasses

Modified Paths:
--------------
    MacRuby/trunk/dispatcher.cpp

Modified: MacRuby/trunk/dispatcher.cpp
===================================================================
--- MacRuby/trunk/dispatcher.cpp	2009-11-07 02:40:26 UTC (rev 2973)
+++ MacRuby/trunk/dispatcher.cpp	2009-11-07 03:11:14 UTC (rev 2974)
@@ -1301,12 +1301,18 @@
     if (overriden == 0) {
 	switch (TYPE(obj)) {
 	    case T_ARRAY:
-		rb_ary_push(obj, other);
-		return obj;
+		if (*(VALUE *)obj == rb_cRubyArray) {
+		    rb_ary_push(obj, other);
+		    return obj;
+		}
+		break;
 
 	    case T_STRING:
-		rb_str_concat(obj, other);
-		return obj;
+		if (*(VALUE *)obj == rb_cCFString) {
+		    rb_str_concat(obj, other);
+		    return obj;
+		}
+		break;
 	}
     }
     return __rb_vm_dispatch(GET_VM(), cache, 0, obj, NULL, selLTLT, NULL, 0, 1,
@@ -1321,13 +1327,19 @@
     if (overriden == 0)
 	switch (TYPE(obj)) {
 	    case T_ARRAY:
-		if (TYPE(other) == T_FIXNUM) {
-		    return rb_ary_entry(obj, FIX2LONG(other));
+		if (*(VALUE *)obj == rb_cRubyArray) {
+		    if (TYPE(other) == T_FIXNUM) {
+			return rb_ary_entry(obj, FIX2LONG(other));
+		    }
+		    return rb_ary_aref(obj, 0, 1, &other);
 		}
-		return rb_ary_aref(obj, 0, 1, &other);
+		break;
 
 	    case T_HASH:
-		return rb_hash_aref(obj, other);
+		if (*(VALUE *)obj == rb_cCFHash) {
+		    return rb_hash_aref(obj, other);
+		}
+		break;
     }
     return __rb_vm_dispatch(GET_VM(), cache, 0, obj, NULL, selAREF, NULL, 0, 1,
 	    &other);
@@ -1341,14 +1353,19 @@
     if (overriden == 0) {
 	switch (TYPE(obj)) {
 	    case T_ARRAY:
-		if (TYPE(other1) == T_FIXNUM) {
-		    rb_ary_store(obj, FIX2LONG(other1), other2);
-		    return other2;
+		if (*(VALUE *)obj == rb_cRubyArray) {
+		    if (TYPE(other1) == T_FIXNUM) {
+			rb_ary_store(obj, FIX2LONG(other1), other2);
+			return other2;
+		    }
 		}
 		break;
 
 	    case T_HASH:
-		return rb_hash_aset(obj, other1, other2);
+		if (*(VALUE *)obj == rb_cCFHash) {
+		    return rb_hash_aset(obj, other1, other2);
+		}
+		break;
 	}
     }
     VALUE args[2] = { other1, other2 };
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091106/4645d4e5/attachment.html>


More information about the macruby-changes mailing list