[前][次][番号順一覧][スレッド一覧]

ruby-changes:28885

From: ko1 <ko1@a...>
Date: Mon, 27 May 2013 01:19:20 +0900 (JST)
Subject: [ruby-changes:28885] ko1:r40937 (trunk): * hash.c (rb_hash_tbl_raw), internal.h: added.

ko1	2013-05-27 01:19:04 +0900 (Mon, 27 May 2013)

  New Revision: 40937

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40937

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/array.c
    trunk/compile.c
    trunk/gc.c
    trunk/hash.c
    trunk/insns.def
    trunk/internal.h
    trunk/process.c
    trunk/thread.c
    trunk/vm_insnhelper.c

Index: array.c
===================================================================
--- array.c	(revision 40936)
+++ array.c	(revision 40937)
@@ -3840,7 +3840,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2) https://github.com/ruby/ruby/blob/trunk/array.c#L3840
     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) https://github.com/ruby/ruby/blob/trunk/array.c#L3881
 
     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) https://github.com/ruby/ruby/blob/trunk/array.c#L3917
 
     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) https://github.com/ruby/ruby/blob/trunk/array.c#L3983
 	    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) https://github.com/ruby/ruby/blob/trunk/array.c#L3992
 	}
 	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) https://github.com/ruby/ruby/blob/trunk/array.c#L4033
     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);
 	    }
 	}
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40936)
+++ ChangeLog	(revision 40937)
@@ -1,3 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May 27 01:15:22 2013  Koichi Sasada  <ko1@a...>
+
+	* 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@r...>
 
 	* tool/make-snapshot: use ENV["AUTOCONF"] instead of directly using
Index: insns.def
===================================================================
--- insns.def	(revision 40936)
+++ insns.def	(revision 40937)
@@ -1272,7 +1272,7 @@ opt_case_dispatch https://github.com/ruby/ruby/blob/trunk/insns.def#L1272
 				   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 {
Index: compile.c
===================================================================
--- compile.c	(revision 40936)
+++ compile.c	(revision 40937)
@@ -3244,7 +3244,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L3244
 	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);
Index: thread.c
===================================================================
--- thread.c	(revision 40936)
+++ thread.c	(revision 40937)
@@ -3881,7 +3881,7 @@ clear_coverage(void) https://github.com/ruby/ruby/blob/trunk/thread.c#L3881
 {
     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);
     }
 }
 
Index: gc.c
===================================================================
--- gc.c	(revision 40936)
+++ gc.c	(revision 40937)
@@ -1979,7 +1979,7 @@ count_objects(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/gc.c#L1979
         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));
Index: process.c
===================================================================
--- process.c	(revision 40936)
+++ process.c	(revision 40937)
@@ -1884,7 +1884,7 @@ rb_check_exec_options(VALUE opthash, VAL https://github.com/ruby/ruby/blob/trunk/process.c#L1884
 {
     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 https://github.com/ruby/ruby/blob/trunk/process.c#L1895
         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) https://github.com/ruby/ruby/blob/trunk/process.c#L1925
     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;
 }
Index: hash.c
===================================================================
--- hash.c	(revision 40936)
+++ hash.c	(revision 40937)
@@ -295,6 +295,12 @@ rb_hash_tbl(VALUE hash) https://github.com/ruby/ruby/blob/trunk/hash.c#L295
     return hash_tbl(hash);
 }
 
+struct st_table *
+rb_hash_tbl_raw(VALUE hash)
+{
+    return hash_tbl(hash);
+}
+
 static void
 rb_hash_modify(VALUE hash)
 {
Index: internal.h
===================================================================
--- internal.h	(revision 40936)
+++ internal.h	(revision 40937)
@@ -189,6 +189,10 @@ void rb_w32_init_file(void); https://github.com/ruby/ruby/blob/trunk/internal.h#L189
 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);
 
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 40936)
+++ vm_insnhelper.c	(revision 40937)
@@ -1091,7 +1091,7 @@ extract_keywords(VALUE *orighash) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1091
 	*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_ise https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1116
 	    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_ise https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1127
 	}
 	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);
 	    }
 	}

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]