1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

RHASH_TBL: is now ext-only

It seems almost no internal codes use RHASH_TBL any longer.  Why not
just eliminate it entirely, so that the macro can be purely ext-only.
This commit is contained in:
卜部昌平 2020-08-17 11:12:23 +09:00
parent d2eeb83634
commit 99093e1600
Notes: git 2020-08-19 15:11:27 +09:00
6 changed files with 10 additions and 17 deletions

View file

@ -252,7 +252,8 @@ rb_coverage_peek_result(VALUE klass)
if (!RTEST(coverages)) {
rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
}
st_foreach(RHASH_TBL(coverages), coverage_peek_result_i, ncoverages);
OBJ_WB_UNPROTECT(coverages);
st_foreach(RHASH_TBL_RAW(coverages), coverage_peek_result_i, ncoverages);
if (current_mode & COVERAGE_TARGET_METHODS) {
rb_objspace_each_objects(method_coverage_i, &ncoverages);

View file

@ -141,7 +141,8 @@ setup_hash(int argc, VALUE *argv)
hash = rb_hash_new();
}
else if (!RHASH_EMPTY_P(hash)) {
st_foreach(RHASH_TBL(hash), set_zero_i, hash);
/* WB: no new reference */
st_foreach(RHASH_TBL_RAW(hash), set_zero_i, hash);
}
return hash;

9
hash.c
View file

@ -1620,23 +1620,16 @@ rb_hash_modify_check(VALUE hash)
}
MJIT_FUNC_EXPORTED struct st_table *
#if RHASH_CONVERT_TABLE_DEBUG
rb_hash_tbl_raw(VALUE hash, const char *file, int line)
{
return ar_force_convert_table(hash, file, line);
}
#else
rb_hash_tbl_raw(VALUE hash)
{
return ar_force_convert_table(hash, NULL, 0);
}
#endif
struct st_table *
rb_hash_tbl(VALUE hash, const char *file, int line)
{
OBJ_WB_UNPROTECT(hash);
return RHASH_TBL_RAW(hash);
return rb_hash_tbl_raw(hash, file, line);
}
static void

View file

@ -46,6 +46,7 @@
/* internal/hash.h */
#undef RHASH_IFNONE
#undef RHASH_SIZE
#undef RHASH_TBL
/* internal/object.h */
#undef ROBJECT_IV_INDEX_TBL

View file

@ -107,13 +107,8 @@ VALUE rb_hash_keys(VALUE hash);
VALUE rb_hash_has_key(VALUE hash, VALUE key);
VALUE rb_hash_compare_by_id_p(VALUE hash);
#if RHASH_CONVERT_TABLE_DEBUG
st_table *rb_hash_tbl_raw(VALUE hash, const char *file, int line);
#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
#else
st_table *rb_hash_tbl_raw(VALUE hash);
#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
#endif
MJIT_SYMBOL_EXPORT_END
#if 0 /* for debug */

View file

@ -388,9 +388,10 @@ struct_make_members_list(va_list ar)
{
char *mem;
VALUE ary, list = rb_ident_hash_new();
st_table *tbl = RHASH_TBL(list);
st_table *tbl = RHASH_TBL_RAW(list);
RBASIC_CLEAR_CLASS(list);
OBJ_WB_UNPROTECT(list);
while ((mem = va_arg(ar, char*)) != 0) {
VALUE sym = rb_sym_intern_ascii_cstr(mem);
if (st_insert(tbl, sym, Qtrue)) {
@ -583,7 +584,8 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
rest = rb_ident_hash_new();
RBASIC_CLEAR_CLASS(rest);
tbl = RHASH_TBL(rest);
OBJ_WB_UNPROTECT(rest);
tbl = RHASH_TBL_RAW(rest);
for (i=0; i<argc; i++) {
VALUE mem = rb_to_symbol(argv[i]);
if (rb_is_attrset_sym(mem)) {