Modified: MacRuby/branches/experimental/hash.c (1903 => 1904)
--- MacRuby/branches/experimental/hash.c 2009-06-20 04:49:53 UTC (rev 1903)
+++ MacRuby/branches/experimental/hash.c 2009-06-20 05:06:56 UTC (rev 1904)
@@ -37,8 +37,11 @@
VALUE rb_cNSMutableHash;
static VALUE envtbl;
-static ID id_hash, id_yield, id_default;
+static ID id_hash, id_yield;
+static void *defaultCache = NULL;
+static SEL selDefault = 0;
+
VALUE
rb_hash(VALUE obj)
{
@@ -469,9 +472,10 @@
{
VALUE val;
- if (!CFDictionaryGetValueIfPresent((CFDictionaryRef)hash, (const void *)RB2OC(key),
+ if (!CFDictionaryGetValueIfPresent((CFDictionaryRef)hash,
+ (const void *)RB2OC(key),
(const void **)&val)) {
- return rb_funcall(hash, id_default, 1, key);
+ return rb_vm_call_with_cache(defaultCache, hash, selDefault, 0, NULL);
}
val = OC2RB(val);
return val;
@@ -2479,9 +2483,11 @@
void
Init_Hash(void)
{
+ selDefault = sel_registerName("default");
+ defaultCache = rb_vm_get_call_cache(selDefault);
+
id_hash = rb_intern("hash");
id_yield = rb_intern("yield");
- id_default = rb_intern("default");
rb_cCFHash = (VALUE)objc_getClass("NSCFDictionary");
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060