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

source_changes at macosforge.org source_changes at macosforge.org
Thu Nov 5 16:34:02 PST 2009


Revision: 2962
          http://trac.macosforge.org/projects/ruby/changeset/2962
Author:   lsansonetti at apple.com
Date:     2009-11-05 16:33:58 -0800 (Thu, 05 Nov 2009)
Log Message:
-----------
added fast #[] and #[]= paths for Hash

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

Modified: MacRuby/trunk/dispatcher.cpp
===================================================================
--- MacRuby/trunk/dispatcher.cpp	2009-11-05 09:02:04 UTC (rev 2961)
+++ MacRuby/trunk/dispatcher.cpp	2009-11-06 00:33:58 UTC (rev 2962)
@@ -1318,12 +1318,16 @@
 rb_vm_fast_aref(VALUE obj, VALUE other, struct mcache *cache,
 		unsigned char overriden)
 {
-    // TODO what about T_HASH?
-    if (overriden == 0 && TYPE(obj) == T_ARRAY) {
-	if (TYPE(other) == T_FIXNUM) {
-	    return rb_ary_entry(obj, FIX2LONG(other));
-	}
-	return rb_ary_aref(obj, 0, 1, &other);
+    if (overriden == 0)
+	switch (TYPE(obj)) {
+	    case T_ARRAY:
+		if (TYPE(other) == T_FIXNUM) {
+		    return rb_ary_entry(obj, FIX2LONG(other));
+		}
+		return rb_ary_aref(obj, 0, 1, &other);
+
+	    case T_HASH:
+		return rb_hash_aref(obj, other);
     }
     return __rb_vm_dispatch(GET_VM(), cache, 0, obj, NULL, selAREF, NULL, 0, 1,
 	    &other);
@@ -1334,11 +1338,17 @@
 rb_vm_fast_aset(VALUE obj, VALUE other1, VALUE other2, struct mcache *cache,
 		unsigned char overriden)
 {
-    // TODO what about T_HASH?
-    if (overriden == 0 && TYPE(obj) == T_ARRAY) {
-	if (TYPE(other1) == T_FIXNUM) {
-	    rb_ary_store(obj, FIX2LONG(other1), other2);
-	    return other2;
+    if (overriden == 0) {
+	switch (TYPE(obj)) {
+	    case T_ARRAY:
+		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);
 	}
     }
     VALUE args[2] = { other1, other2 };
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091105/48a8746c/attachment.html>


More information about the macruby-changes mailing list