summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-23 05:23:12 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-23 05:23:12 +0000
commitbf70582cf30ae6f715769c519f451411f5d2a577 (patch)
treeb3eb8e2975df384946ad70572e1e3387a6c3127c /hash.c
parent6f82a67fd0035fcd2802f1564165d5211bc98ea2 (diff)
2000-02-23
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index ea42674..bfef46b 100644
--- a/hash.c
+++ b/hash.c
@@ -89,7 +89,23 @@ rb_any_hash(a)
break;
case T_STRING:
+#if 0
hval = rb_str_hash(a);
+#else
+ {
+ register const char *p = RSTRING(a)->ptr;
+ register int len = RSTRING(a)->len;
+ register unsigned int h = 0, g;
+
+ while (len--) {
+ h = ( h << 4 ) + *p++;
+ if ( g = h & 0xF0000000 )
+ h ^= g >> 24;
+ h &= ~g;
+ }
+ hval = h;
+ }
+#endif
break;
default:
@@ -648,9 +664,11 @@ inspect_i(key, value, str)
}
str2 = rb_inspect(key);
rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
+ OBJ_INFECT(str, str2);
rb_str_cat(str, "=>", 2);
str2 = rb_inspect(value);
rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
+ OBJ_INFECT(str, str2);
return ST_CONTINUE;
}
@@ -664,7 +682,8 @@ inspect_hash(hash)
str = rb_str_new2("{");
st_foreach(RHASH(hash)->tbl, inspect_i, str);
rb_str_cat(str, "}", 1);
-
+
+ OBJ_INFECT(str, hash);
return str;
}