summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-26 16:19:04 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-26 16:19:04 +0000
commitc4c821a7d7f2229a7c8d2c36cdc6b20668101081 (patch)
treefa38a537cd03cadb33f41b83f2912373bdad876f
parent9ae121d6df75c50bf114aaa3127715ad3194c047 (diff)
* hash.c (rb_hash_tbl_raw), internal.h: added.
Returns st_table without shading hash. * array.c: use rb_hash_tbl_raw() for read-only purpose. * compile.c (iseq_compile_each): ditto. * gc.c (count_objects): ditto. * insns.def: ditto. * process.c: ditto. * thread.c (clear_coverage): ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog19
-rw-r--r--array.c16
-rw-r--r--compile.c2
-rw-r--r--gc.c2
-rw-r--r--hash.c6
-rw-r--r--insns.def2
-rw-r--r--internal.h4
-rw-r--r--process.c6
-rw-r--r--thread.c2
-rw-r--r--vm_insnhelper.c8
10 files changed, 48 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a69f653c8..76cf60ebf6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+Mon May 27 01:15:22 2013 Koichi Sasada <ko1@atdot.net>
+
+ * hash.c (rb_hash_tbl_raw), internal.h: added.
+ Returns st_table without shading hash.
+
+ * array.c: use rb_hash_tbl_raw() for read-only purpose.
+
+ * compile.c (iseq_compile_each): ditto.
+
+ * gc.c (count_objects): ditto.
+
+ * insns.def: ditto.
+
+ * process.c: ditto.
+
+ * thread.c (clear_coverage): ditto.
+
+ * vm_insnhelper.c: ditto.
+
Mon May 27 00:31:09 2013 NARUSE, Yui <naruse@ruby-lang.org>
* tool/make-snapshot: use ENV["AUTOCONF"] instead of directly using
diff --git a/array.c b/array.c
index f5f6d6f82f..bb5e4a93b6 100644
--- a/array.c
+++ b/array.c
@@ -3840,7 +3840,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
ary3 = rb_ary_new();
for (i=0; i<RARRAY_LEN(ary1); i++) {
- if (st_lookup(RHASH_TBL(hash), RARRAY_AREF(ary1, i), 0)) continue;
+ if (st_lookup(rb_hash_tbl_raw(hash), RARRAY_AREF(ary1, i), 0)) continue;
rb_ary_push(ary3, rb_ary_elt(ary1, i));
}
ary_recycle_hash(hash);
@@ -3881,7 +3881,7 @@ rb_ary_and(VALUE ary1, VALUE ary2)
for (i=0; i<RARRAY_LEN(ary1); i++) {
vv = (st_data_t)(v = rb_ary_elt(ary1, i));
- if (st_delete(RHASH_TBL(hash), &vv, 0)) {
+ if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) {
rb_ary_push(ary3, v);
}
}
@@ -3917,13 +3917,13 @@ rb_ary_or(VALUE ary1, VALUE ary2)
for (i=0; i<RARRAY_LEN(ary1); i++) {
vv = (st_data_t)(v = rb_ary_elt(ary1, i));
- if (st_delete(RHASH_TBL(hash), &vv, 0)) {
+ if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) {
rb_ary_push(ary3, v);
}
}
for (i=0; i<RARRAY_LEN(ary2); i++) {
vv = (st_data_t)(v = rb_ary_elt(ary2, i));
- if (st_delete(RHASH_TBL(hash), &vv, 0)) {
+ if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) {
rb_ary_push(ary3, v);
}
}
@@ -3983,7 +3983,7 @@ rb_ary_uniq_bang(VALUE ary)
FL_SET_EMBED(ary);
}
ary_resize_capa(ary, i);
- st_foreach(RHASH_TBL(hash), push_value, ary);
+ st_foreach(rb_hash_tbl_raw(hash), push_value, ary);
}
else {
hash = ary_make_hash(ary);
@@ -3992,7 +3992,7 @@ rb_ary_uniq_bang(VALUE ary)
}
for (i=j=0; i<RARRAY_LEN(ary); i++) {
st_data_t vv = (st_data_t)(v = rb_ary_elt(ary, i));
- if (st_delete(RHASH_TBL(hash), &vv, 0)) {
+ if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) {
rb_ary_store(ary, j++, v);
}
}
@@ -4033,14 +4033,14 @@ rb_ary_uniq(VALUE ary)
if (rb_block_given_p()) {
hash = ary_make_hash_by(ary);
uniq = ary_new(rb_obj_class(ary), RHASH_SIZE(hash));
- st_foreach(RHASH_TBL(hash), push_value, uniq);
+ st_foreach(rb_hash_tbl_raw(hash), push_value, uniq);
}
else {
hash = ary_make_hash(ary);
uniq = ary_new(rb_obj_class(ary), RHASH_SIZE(hash));
for (i=0; i<RARRAY_LEN(ary); i++) {
st_data_t vv = (st_data_t)(v = rb_ary_elt(ary, i));
- if (st_delete(RHASH_TBL(hash), &vv, 0)) {
+ if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) {
rb_ary_push(uniq, v);
}
}
diff --git a/compile.c b/compile.c
index d80d409865..70db48c6a0 100644
--- a/compile.c
+++ b/compile.c
@@ -3244,7 +3244,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
INIT_ANCHOR(body_seq);
INIT_ANCHOR(cond_seq);
- RHASH_TBL(literals)->type = &cdhash_type;
+ rb_hash_tbl_raw(literals)->type = &cdhash_type;
if (node->nd_head == 0) {
COMPILE_(ret, "when", node->nd_body, poped);
diff --git a/gc.c b/gc.c
index d9f008de25..4dc1b2fd82 100644
--- a/gc.c
+++ b/gc.c
@@ -1979,7 +1979,7 @@ count_objects(int argc, VALUE *argv, VALUE os)
hash = rb_hash_new();
}
else if (!RHASH_EMPTY_P(hash)) {
- st_foreach(RHASH_TBL(hash), set_zero, hash);
+ st_foreach(RHASH_TBL_RAW(hash), set_zero, hash);
}
rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), SIZET2NUM(total));
rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(freed));
diff --git a/hash.c b/hash.c
index bd14e36ffe..67759b61cd 100644
--- a/hash.c
+++ b/hash.c
@@ -295,6 +295,12 @@ rb_hash_tbl(VALUE hash)
return hash_tbl(hash);
}
+struct st_table *
+rb_hash_tbl_raw(VALUE hash)
+{
+ return hash_tbl(hash);
+}
+
static void
rb_hash_modify(VALUE hash)
{
diff --git a/insns.def b/insns.def
index e2c2c993e4..2a51424a0d 100644
--- a/insns.def
+++ b/insns.def
@@ -1272,7 +1272,7 @@ opt_case_dispatch
BIGNUM_REDEFINED_OP_FLAG |
STRING_REDEFINED_OP_FLAG)) {
st_data_t val;
- if (st_lookup(RHASH_TBL(hash), key, &val)) {
+ if (st_lookup(RHASH_TBL_RAW(hash), key, &val)) {
JUMP(FIX2INT((VALUE)val));
}
else {
diff --git a/internal.h b/internal.h
index 2cf4ea7c3b..b49e748f16 100644
--- a/internal.h
+++ b/internal.h
@@ -189,6 +189,10 @@ void rb_w32_init_file(void);
void Init_heap(void);
void *ruby_mimmalloc(size_t size);
+/* hash.c */
+struct st_table *rb_hash_tbl_raw(VALUE hash);
+#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
+
/* inits.c */
void rb_call_inits(void);
diff --git a/process.c b/process.c
index e9e0fc88fd..8bb43c4494 100644
--- a/process.c
+++ b/process.c
@@ -1884,7 +1884,7 @@ rb_check_exec_options(VALUE opthash, VALUE execarg_obj)
{
if (RHASH_EMPTY_P(opthash))
return;
- st_foreach(RHASH_TBL(opthash), check_exec_options_i, (st_data_t)execarg_obj);
+ st_foreach(rb_hash_tbl_raw(opthash), check_exec_options_i, (st_data_t)execarg_obj);
}
VALUE
@@ -1895,7 +1895,7 @@ rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash)
return Qnil;
args[0] = execarg_obj;
args[1] = Qnil;
- st_foreach(RHASH_TBL(opthash), check_exec_options_i_extract, (st_data_t)args);
+ st_foreach(rb_hash_tbl_raw(opthash), check_exec_options_i_extract, (st_data_t)args);
return args[1];
}
@@ -1925,7 +1925,7 @@ rb_check_exec_env(VALUE hash)
VALUE env;
env = hide_obj(rb_ary_new());
- st_foreach(RHASH_TBL(hash), check_exec_env_i, (st_data_t)env);
+ st_foreach(rb_hash_tbl_raw(hash), check_exec_env_i, (st_data_t)env);
return env;
}
diff --git a/thread.c b/thread.c
index 17b7709194..da3fb2105d 100644
--- a/thread.c
+++ b/thread.c
@@ -3881,7 +3881,7 @@ clear_coverage(void)
{
VALUE coverages = rb_get_coverages();
if (RTEST(coverages)) {
- st_foreach(RHASH_TBL(coverages), clear_coverage_i, 0);
+ st_foreach(rb_hash_tbl_raw(coverages), clear_coverage_i, 0);
}
}
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index bd3620a95f..88def22938 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1091,7 +1091,7 @@ extract_keywords(VALUE *orighash)
*orighash = 0;
return hash;
}
- st_foreach(RHASH_TBL(hash), separate_symbol, (st_data_t)&parthash);
+ st_foreach(rb_hash_tbl_raw(hash), separate_symbol, (st_data_t)&parthash);
*orighash = parthash[1];
return parthash[0];
}
@@ -1116,7 +1116,7 @@ vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, VALUE *orig_argv, V
VALUE missing = Qnil;
for (; i < iseq->arg_keyword_required; i++) {
VALUE keyword = ID2SYM(iseq->arg_keyword_table[i]);
- if (st_lookup(RHASH_TBL(keyword_hash), (st_data_t)keyword, 0))
+ if (st_lookup(rb_hash_tbl_raw(keyword_hash), (st_data_t)keyword, 0))
continue;
if (NIL_P(missing)) missing = rb_ary_tmp_new(1);
rb_ary_push(missing, keyword);
@@ -1127,9 +1127,9 @@ vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, VALUE *orig_argv, V
}
if (iseq->arg_keyword_check) {
for (j = i; i < iseq->arg_keywords; i++) {
- if (st_lookup(RHASH_TBL(keyword_hash), ID2SYM(iseq->arg_keyword_table[i]), 0)) j++;
+ if (st_lookup(rb_hash_tbl_raw(keyword_hash), ID2SYM(iseq->arg_keyword_table[i]), 0)) j++;
}
- if (RHASH_TBL(keyword_hash)->num_entries > (unsigned int) j) {
+ if (RHASH_SIZE(keyword_hash) > j) {
unknown_keyword_error(iseq, keyword_hash);
}
}