summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-12 14:47:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-12 14:47:23 +0000
commitd410639a6d422e0ae032f049ccfbbbb45b312d6f (patch)
tree7f967d0f5320dea31975c536b705cedc1db23db5 /hash.c
parent17c48bebf87828abeb5be91ed8ba0a2b72bc5479 (diff)
* compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
(syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer), (run_final), hash.c (rb_hash_aref, rb_hash_lookup2), (rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i), iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink), thread.c (rb_thread_local_aref), variable.c (generic_ivar_remove, ivar_get, rb_const_get_0), (rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method), vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method), ext/iconv/iconv.c (map_charset): use st_data_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/hash.c b/hash.c
index 3e1731d5a3..8b165735d9 100644
--- a/hash.c
+++ b/hash.c
@@ -506,23 +506,23 @@ rb_hash_rehash(VALUE hash)
VALUE
rb_hash_aref(VALUE hash, VALUE key)
{
- VALUE val;
+ st_data_t val;
if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
return rb_funcall(hash, id_default, 1, key);
}
- return val;
+ return (VALUE)val;
}
VALUE
rb_hash_lookup2(VALUE hash, VALUE key, VALUE def)
{
- VALUE val;
+ st_data_t val;
if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
return def; /* without Hash#default */
}
- return val;
+ return (VALUE)val;
}
VALUE
@@ -564,7 +564,7 @@ static VALUE
rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
{
VALUE key, if_none;
- VALUE val;
+ st_data_t val;
long block_given;
rb_scan_args(argc, argv, "11", &key, &if_none);
@@ -584,7 +584,7 @@ rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
}
return if_none;
}
- return val;
+ return (VALUE)val;
}
VALUE
@@ -1094,6 +1094,12 @@ rb_hash_clear(VALUE hash)
return hash;
}
+static st_data_t
+copy_str_key(st_data_t str)
+{
+ return (st_data_t)rb_str_new4((VALUE)str);
+}
+
/*
* call-seq:
* hsh[key] = value -> value
@@ -1121,7 +1127,7 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val)
st_insert(RHASH(hash)->ntbl, key, val);
}
else {
- st_insert2(RHASH(hash)->ntbl, key, val, rb_str_new4);
+ st_insert2(RHASH(hash)->ntbl, key, val, copy_str_key);
}
return val;
}
@@ -1548,14 +1554,14 @@ static int
eql_i(VALUE key, VALUE val1, VALUE arg)
{
struct equal_data *data = (struct equal_data *)arg;
- VALUE val2;
+ st_data_t val2;
if (key == Qundef) return ST_CONTINUE;
if (!st_lookup(data->tbl, key, &val2)) {
data->result = Qfalse;
return ST_STOP;
}
- if (!(data->eql ? rb_eql(val1, val2) : (int)rb_equal(val1, val2))) {
+ if (!(data->eql ? rb_eql(val1, (VALUE)val2) : (int)rb_equal(val1, (VALUE)val2))) {
data->result = Qfalse;
return ST_STOP;
}