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

* remove trailing spaces, expand tabs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
svn 2018-10-30 22:12:12 +00:00
parent 8f675cdd00
commit d4f1187d31
9 changed files with 155 additions and 155 deletions

View file

@ -4421,9 +4421,9 @@ ary_recycle_hash(VALUE hash)
{ {
assert(RBASIC_CLASS(hash) == 0); assert(RBASIC_CLASS(hash) == 0);
if (RHASH_TABLE_P(hash)) { if (RHASH_TABLE_P(hash)) {
st_table *tbl = RHASH_ST_TABLE(hash); st_table *tbl = RHASH_ST_TABLE(hash);
st_free_table(tbl); st_free_table(tbl);
RHASH_CLEAR(hash); RHASH_CLEAR(hash);
} }
} }
@ -4467,7 +4467,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
hash = ary_make_hash(ary2); hash = ary_make_hash(ary2);
for (i=0; i<RARRAY_LEN(ary1); i++) { for (i=0; i<RARRAY_LEN(ary1); i++) {
if (rb_hash_stlike_lookup(hash, RARRAY_AREF(ary1, i), NULL)) continue; if (rb_hash_stlike_lookup(hash, RARRAY_AREF(ary1, i), NULL)) continue;
rb_ary_push(ary3, rb_ary_elt(ary1, i)); rb_ary_push(ary3, rb_ary_elt(ary1, i));
} }
ary_recycle_hash(hash); ary_recycle_hash(hash);
@ -4573,7 +4573,7 @@ rb_ary_and(VALUE ary1, VALUE ary2)
for (i=0; i<RARRAY_LEN(ary1); i++) { for (i=0; i<RARRAY_LEN(ary1); i++) {
v = RARRAY_AREF(ary1, i); v = RARRAY_AREF(ary1, i);
vv = (st_data_t)v; vv = (st_data_t)v;
if (rb_hash_stlike_delete(hash, &vv, 0)) { if (rb_hash_stlike_delete(hash, &vv, 0)) {
rb_ary_push(ary3, v); rb_ary_push(ary3, v);
} }
} }

View file

@ -1807,7 +1807,7 @@ unknown_keyword_error(VALUE hash, const ID *table, int keywords)
int i; int i;
for (i = 0; i < keywords; i++) { for (i = 0; i < keywords; i++) {
st_data_t key = ID2SYM(table[i]); st_data_t key = ID2SYM(table[i]);
rb_hash_stlike_delete(hash, &key, NULL); rb_hash_stlike_delete(hash, &key, NULL);
} }
rb_keyword_error("unknown", rb_hash_keys(hash)); rb_keyword_error("unknown", rb_hash_keys(hash));
} }

View file

@ -7990,7 +7990,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
int i; int i;
VALUE map = rb_hash_new_with_size(RARRAY_LEN(op)/2); VALUE map = rb_hash_new_with_size(RARRAY_LEN(op)/2);
RHASH_TBL_RAW(map)->type = &cdhash_type; RHASH_TBL_RAW(map)->type = &cdhash_type;
op = rb_to_array_type(op); op = rb_to_array_type(op);
for (i=0; i<RARRAY_LEN(op); i+=2) { for (i=0; i<RARRAY_LEN(op); i+=2) {
VALUE key = RARRAY_AREF(op, i); VALUE key = RARRAY_AREF(op, i);

10
gc.c
View file

@ -3358,12 +3358,12 @@ obj_memsize_of(VALUE obj, int use_all_types)
break; break;
case T_HASH: case T_HASH:
if (RHASH_ARRAY_P(obj)) { if (RHASH_ARRAY_P(obj)) {
size += sizeof(li_table); size += sizeof(li_table);
} }
else { else {
VM_ASSERT(RHASH_ST_TABLE(obj) != NULL); VM_ASSERT(RHASH_ST_TABLE(obj) != NULL);
size += st_memsize(RHASH_ST_TABLE(obj)); size += st_memsize(RHASH_ST_TABLE(obj));
} }
break; break;
case T_REGEXP: case T_REGEXP:
if (RREGEXP_PTR(obj)) { if (RREGEXP_PTR(obj)) {
@ -4739,7 +4739,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
break; break;
case T_HASH: case T_HASH:
mark_hash(objspace, obj); mark_hash(objspace, obj);
break; break;
case T_STRING: case T_STRING:

264
hash.c
View file

@ -382,7 +382,7 @@ rb_hash_dump(VALUE hash)
for (i=0; i<bound; i++) { for (i=0; i<bound; i++) {
li_table_entry *cur_entry = RHASH_ARRAY_REF(hash, i); li_table_entry *cur_entry = RHASH_ARRAY_REF(hash, i);
st_data_t k, v; st_data_t k, v;
if (!empty_entry(cur_entry)) { if (!empty_entry(cur_entry)) {
char b1[0x100], b2[0x100]; char b1[0x100], b2[0x100];
/* h = cur_entry->hash; */ /* h = cur_entry->hash; */
@ -435,7 +435,7 @@ hash_verify_(VALUE hash, const char *file, int line)
if (RHASH_TRANSIENT_P(hash)) { if (RHASH_TRANSIENT_P(hash)) {
volatile st_data_t MAYBE_UNUSED(key) = RHASH_ARRAY_REF(hash, 0)->key; /* read */ volatile st_data_t MAYBE_UNUSED(key) = RHASH_ARRAY_REF(hash, 0)->key; /* read */
HASH_ASSERT(RHASH_ARRAY(hash) != NULL); HASH_ASSERT(RHASH_ARRAY(hash) != NULL);
HASH_ASSERT(rb_transient_heap_managed_ptr_p(RHASH_ARRAY(hash))); HASH_ASSERT(rb_transient_heap_managed_ptr_p(RHASH_ARRAY(hash)));
} }
return hash; return hash;
@ -544,11 +544,11 @@ linear_init_table(VALUE hash)
tab = (li_table*)rb_transient_heap_alloc(hash, sizeof(li_table)); tab = (li_table*)rb_transient_heap_alloc(hash, sizeof(li_table));
if (tab != NULL) { if (tab != NULL) {
RHASH_SET_TRANSIENT_FLAG(hash); RHASH_SET_TRANSIENT_FLAG(hash);
} }
else { else {
RHASH_UNSET_TRANSIENT_FLAG(hash); RHASH_UNSET_TRANSIENT_FLAG(hash);
tab = (li_table*)ruby_xmalloc(sizeof(li_table)); tab = (li_table*)ruby_xmalloc(sizeof(li_table));
} }
RHASH_ARRAY_SIZE_SET(hash, 0); RHASH_ARRAY_SIZE_SET(hash, 0);
@ -580,7 +580,7 @@ linear_free_and_clear_table(VALUE hash)
if (tab) { if (tab) {
if (RHASH_TRANSIENT_P(hash)) { if (RHASH_TRANSIENT_P(hash)) {
RHASH_UNSET_TRANSIENT_FLAG(hash); RHASH_UNSET_TRANSIENT_FLAG(hash);
} }
else { else {
ruby_xfree(RHASH_ARRAY(hash)); ruby_xfree(RHASH_ARRAY(hash));
} }
@ -642,11 +642,11 @@ linear_force_convert_table(VALUE hash, const char *file, int line)
for (i = 0; i < bound; i++) { for (i = 0; i < bound; i++) {
entry = RHASH_ARRAY_REF(hash, i); entry = RHASH_ARRAY_REF(hash, i);
if (empty_entry(entry)) continue; if (empty_entry(entry)) continue;
st_add_direct_with_hash(new_tab, entry->key, entry->record, entry->hash); st_add_direct_with_hash(new_tab, entry->key, entry->record, entry->hash);
} }
linear_free_and_clear_table(hash); linear_free_and_clear_table(hash);
} }
else { else {
new_tab = st_init_table(&objhash); new_tab = st_init_table(&objhash);
@ -660,7 +660,7 @@ static li_table *
hash_ltbl(VALUE hash) hash_ltbl(VALUE hash)
{ {
if (RHASH_TABLE_EMPTY(hash)) { if (RHASH_TABLE_EMPTY(hash)) {
linear_init_table(hash); linear_init_table(hash);
} }
return RHASH_ARRAY(hash); return RHASH_ARRAY(hash);
} }
@ -711,7 +711,7 @@ linear_add_direct_with_hash(VALUE hash, st_data_t key, st_data_t val, st_hash_t
li_table_entry *entry; li_table_entry *entry;
if (RHASH_ARRAY_SIZE(hash) >= RHASH_ARRAY_MAX_SIZE) { if (RHASH_ARRAY_SIZE(hash) >= RHASH_ARRAY_MAX_SIZE) {
return 1; return 1;
} }
else { else {
if (UNLIKELY(bin >= RHASH_ARRAY_MAX_BOUND)) { if (UNLIKELY(bin >= RHASH_ARRAY_MAX_BOUND)) {
@ -808,7 +808,7 @@ linear_foreach_check(VALUE hash, int (*func)(ANYARGS), st_data_t arg,
static int static int
linear_update(VALUE hash, st_data_t key, linear_update(VALUE hash, st_data_t key,
st_update_callback_func *func, st_data_t arg) st_update_callback_func *func, st_data_t arg)
{ {
int retval, existing; int retval, existing;
uint8_t bin; uint8_t bin;
@ -910,7 +910,7 @@ linear_delete(VALUE hash, st_data_t *key, st_data_t *value)
{ {
st_index_t bin; st_index_t bin;
st_hash_t hash_value = do_hash(*key); st_hash_t hash_value = do_hash(*key);
bin = find_entry(hash, hash_value, *key); bin = find_entry(hash, hash_value, *key);
@ -1035,25 +1035,25 @@ void
rb_hash_transient_heap_evacuate(VALUE hash, int promote) rb_hash_transient_heap_evacuate(VALUE hash, int promote)
{ {
if (RHASH_TRANSIENT_P(hash)) { if (RHASH_TRANSIENT_P(hash)) {
li_table *new_tab; li_table *new_tab;
li_table *old_tab = RHASH_ARRAY(hash); li_table *old_tab = RHASH_ARRAY(hash);
if (UNLIKELY(old_tab == NULL)) { if (UNLIKELY(old_tab == NULL)) {
rb_gc_force_recycle(hash); rb_gc_force_recycle(hash);
return; return;
} }
HASH_ASSERT(old_tab != NULL); HASH_ASSERT(old_tab != NULL);
if (promote) { if (promote) {
promote: promote:
new_tab = ruby_xmalloc(sizeof(li_table)); new_tab = ruby_xmalloc(sizeof(li_table));
RHASH_UNSET_TRANSIENT_FLAG(hash); RHASH_UNSET_TRANSIENT_FLAG(hash);
} }
else { else {
new_tab = rb_transient_heap_alloc(hash, sizeof(li_table)); new_tab = rb_transient_heap_alloc(hash, sizeof(li_table));
if (new_tab == NULL) goto promote; if (new_tab == NULL) goto promote;
} }
*new_tab = *old_tab; *new_tab = *old_tab;
RHASH_ARRAY_SET(hash, new_tab); RHASH_ARRAY_SET(hash, new_tab);
} }
hash_verify(hash); hash_verify(hash);
} }
@ -1114,11 +1114,11 @@ hash_linear_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int err
switch (status) { switch (status) {
case ST_DELETE: case ST_DELETE:
return ST_DELETE; return ST_DELETE;
case ST_CONTINUE: case ST_CONTINUE:
break; break;
case ST_STOP: case ST_STOP:
return ST_STOP; return ST_STOP;
} }
return ST_CHECK; return ST_CHECK;
} }
@ -1186,7 +1186,7 @@ hash_foreach_call(VALUE arg)
(st_data_t)arg, (st_data_t)Qundef); (st_data_t)arg, (st_data_t)Qundef);
} }
if (ret) { if (ret) {
rb_raise(rb_eRuntimeError, "ret: %d, hash modified during iteration", ret); rb_raise(rb_eRuntimeError, "ret: %d, hash modified during iteration", ret);
} }
return Qnil; return Qnil;
} }
@ -1266,9 +1266,9 @@ hash_dup(VALUE hash, VALUE klass, VALUE flags)
VALUE ret = hash_alloc_flags(klass, flags, VALUE ret = hash_alloc_flags(klass, flags,
RHASH_IFNONE(hash)); RHASH_IFNONE(hash));
if (!RHASH_EMPTY_P(hash)) { if (!RHASH_EMPTY_P(hash)) {
if (RHASH_ARRAY_P(hash)) if (RHASH_ARRAY_P(hash))
linear_copy(ret, hash); linear_copy(ret, hash);
else if (RHASH_TABLE_P(hash)) else if (RHASH_TABLE_P(hash))
RHASH_ST_TABLE_SET(ret, st_copy(RHASH_ST_TABLE(hash))); RHASH_ST_TABLE_SET(ret, st_copy(RHASH_ST_TABLE(hash)));
} }
return ret; return ret;
@ -1498,15 +1498,15 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
VALUE hash, tmp; VALUE hash, tmp;
if (argc == 1) { if (argc == 1) {
tmp = rb_hash_s_try_convert(Qnil, argv[0]); //TODO tmp array flag tmp = rb_hash_s_try_convert(Qnil, argv[0]); //TODO tmp array flag
if (!NIL_P(tmp)) { if (!NIL_P(tmp)) {
hash = hash_alloc(klass); hash = hash_alloc(klass);
if (RHASH_ARRAY_P(tmp)) { if (RHASH_ARRAY_P(tmp)) {
linear_copy(hash, tmp); linear_copy(hash, tmp);
} }
else { else {
RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(tmp))); RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(tmp)));
} }
return hash; return hash;
} }
@ -1596,10 +1596,10 @@ static int
rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg) rb_hash_rehash_i(VALUE key, VALUE value, VALUE arg)
{ {
if (RHASH_ARRAY_P(arg)) { if (RHASH_ARRAY_P(arg)) {
linear_insert(arg, (st_data_t)key, (st_data_t)value); linear_insert(arg, (st_data_t)key, (st_data_t)value);
} }
else { else {
st_insert(RHASH_ST_TABLE(arg), (st_data_t)key, (st_data_t)value); st_insert(RHASH_ST_TABLE(arg), (st_data_t)key, (st_data_t)value);
} }
return ST_CONTINUE; return ST_CONTINUE;
} }
@ -1635,22 +1635,22 @@ rb_hash_rehash(VALUE hash)
} }
rb_hash_modify_check(hash); rb_hash_modify_check(hash);
if (RHASH_ARRAY_P(hash)) { if (RHASH_ARRAY_P(hash)) {
tmp = hash_alloc(0); tmp = hash_alloc(0);
linear_init_table(tmp); linear_init_table(tmp);
rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp); rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
linear_free_and_clear_table(hash); linear_free_and_clear_table(hash);
linear_copy(hash, tmp); linear_copy(hash, tmp);
linear_free_and_clear_table(tmp); linear_free_and_clear_table(tmp);
} }
else if (RHASH_TABLE_P(hash)) { else if (RHASH_TABLE_P(hash)) {
st_table *old_tab = RHASH_ST_TABLE(hash); st_table *old_tab = RHASH_ST_TABLE(hash);
tmp = hash_alloc(0); tmp = hash_alloc(0);
tbl = st_init_table_with_size(old_tab->type, old_tab->num_entries); tbl = st_init_table_with_size(old_tab->type, old_tab->num_entries);
RHASH_ST_TABLE_SET(tmp, tbl); RHASH_ST_TABLE_SET(tmp, tbl);
rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp); rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
st_free_table(old_tab); st_free_table(old_tab);
RHASH_ST_TABLE_SET(hash, tbl); RHASH_ST_TABLE_SET(hash, tbl);
RHASH_CLEAR(tmp); RHASH_CLEAR(tmp);
} }
hash_verify(hash); hash_verify(hash);
return hash; return hash;
@ -1690,10 +1690,10 @@ rb_hash_aref(VALUE hash, VALUE key)
st_data_t val; st_data_t val;
if (RHASH_ARRAY_P(hash) && linear_lookup(hash, key, &val)) { if (RHASH_ARRAY_P(hash) && linear_lookup(hash, key, &val)) {
return (VALUE)val; return (VALUE)val;
} }
else if (RHASH_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, &val)) { else if (RHASH_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, &val)) {
return (VALUE)val; return (VALUE)val;
} }
hash_verify(hash); hash_verify(hash);
return rb_hash_default_value(hash, key); return rb_hash_default_value(hash, key);
@ -1775,19 +1775,19 @@ rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
rb_warn("block supersedes default value argument"); rb_warn("block supersedes default value argument");
} }
if (RHASH_ARRAY_P(hash) && linear_lookup(hash, key, &val)) { if (RHASH_ARRAY_P(hash) && linear_lookup(hash, key, &val)) {
return (VALUE)val; return (VALUE)val;
} }
else if (RHASH_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, &val)) { else if (RHASH_TABLE_P(hash) && st_lookup(RHASH_ST_TABLE(hash), key, &val)) {
return (VALUE)val; return (VALUE)val;
} }
if (block_given) return rb_yield(key); if (block_given) return rb_yield(key);
if (argc == 1) { if (argc == 1) {
VALUE desc = rb_protect(rb_inspect, key, 0); VALUE desc = rb_protect(rb_inspect, key, 0);
if (NIL_P(desc)) { if (NIL_P(desc)) {
desc = rb_any_to_s(key); desc = rb_any_to_s(key);
} }
desc = rb_str_ellipsize(desc, 65); desc = rb_str_ellipsize(desc, 65);
rb_key_err_raise(rb_sprintf("key not found: %"PRIsVALUE, desc), hash, key); rb_key_err_raise(rb_sprintf("key not found: %"PRIsVALUE, desc), hash, key);
} }
hash_verify(hash); hash_verify(hash);
return argv[1]; return argv[1];
@ -2092,26 +2092,26 @@ rb_hash_shift(VALUE hash)
if (RHASH_ARRAY_P(hash)) { if (RHASH_ARRAY_P(hash)) {
var.key = Qundef; var.key = Qundef;
if (RHASH_ITER_LEV(hash) == 0) { if (RHASH_ITER_LEV(hash) == 0) {
if (linear_shift(hash, &var.key, &var.val)) { if (linear_shift(hash, &var.key, &var.val)) {
return rb_assoc_new(var.key, var.val); return rb_assoc_new(var.key, var.val);
} }
} }
else { else {
rb_hash_foreach(hash, shift_i_safe, (VALUE)&var); rb_hash_foreach(hash, shift_i_safe, (VALUE)&var);
if (var.key != Qundef) { if (var.key != Qundef) {
rb_hash_delete_entry(hash, var.key); rb_hash_delete_entry(hash, var.key);
return rb_assoc_new(var.key, var.val); return rb_assoc_new(var.key, var.val);
} }
} }
} }
if (RHASH_TABLE_P(hash)) { if (RHASH_TABLE_P(hash)) {
var.key = Qundef; var.key = Qundef;
if (RHASH_ITER_LEV(hash) == 0) { if (RHASH_ITER_LEV(hash) == 0) {
if (st_shift(RHASH_ST_TABLE(hash), &var.key, &var.val)) { if (st_shift(RHASH_ST_TABLE(hash), &var.key, &var.val)) {
return rb_assoc_new(var.key, var.val); return rb_assoc_new(var.key, var.val);
} }
} }
else { else {
rb_hash_foreach(hash, shift_i_safe, (VALUE)&var); rb_hash_foreach(hash, shift_i_safe, (VALUE)&var);
if (var.key != Qundef) { if (var.key != Qundef) {
rb_hash_delete_entry(hash, var.key); rb_hash_delete_entry(hash, var.key);
@ -2511,7 +2511,7 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val)
if (RHASH_TABLE_EMPTY(hash)) { if (RHASH_TABLE_EMPTY(hash)) {
if (iter_lev > 0) no_new_key(); if (iter_lev > 0) no_new_key();
linear_init_table(hash); linear_init_table(hash);
} }
if (RHASH_TYPE(hash) == &identhash || rb_obj_class(key) != rb_cString) { if (RHASH_TYPE(hash) == &identhash || rb_obj_class(key) != rb_cString) {
@ -2543,22 +2543,22 @@ rb_hash_initialize_copy(VALUE hash, VALUE hash2)
if (hash == hash2) return hash; if (hash == hash2) return hash;
if (RHASH_ARRAY_P(hash2)) { if (RHASH_ARRAY_P(hash2)) {
if (RHASH_ARRAY_P(hash)) linear_free_and_clear_table(hash); if (RHASH_ARRAY_P(hash)) linear_free_and_clear_table(hash);
linear_copy(hash, hash2); linear_copy(hash, hash2);
if (RHASH_ARRAY_SIZE(hash)) if (RHASH_ARRAY_SIZE(hash))
rb_hash_rehash(hash); rb_hash_rehash(hash);
} }
else if (RHASH_TABLE_P(hash2)) { else if (RHASH_TABLE_P(hash2)) {
if (RHASH_TABLE_P(hash)) st_free_table(RHASH_ST_TABLE(hash)); if (RHASH_TABLE_P(hash)) st_free_table(RHASH_ST_TABLE(hash));
RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(hash2))); RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(hash2)));
if (RHASH_ST_TABLE(hash)->num_entries) if (RHASH_ST_TABLE(hash)->num_entries)
rb_hash_rehash(hash); rb_hash_rehash(hash);
} }
else if (RHASH_ARRAY_P(hash)) { else if (RHASH_ARRAY_P(hash)) {
linear_clear(hash); linear_clear(hash);
} }
else if (RHASH_TABLE_P(hash)) { else if (RHASH_TABLE_P(hash)) {
st_clear(RHASH_ST_TABLE(hash)); st_clear(RHASH_ST_TABLE(hash));
} }
COPY_DEFAULT(hash, hash2); COPY_DEFAULT(hash, hash2);
@ -3096,20 +3096,20 @@ rb_hash_keys(VALUE hash)
if (size == 0) return keys; if (size == 0) return keys;
if (ST_DATA_COMPATIBLE_P(VALUE)) { if (ST_DATA_COMPATIBLE_P(VALUE)) {
if (RHASH_ARRAY_P(hash)) { if (RHASH_ARRAY_P(hash)) {
rb_gc_writebarrier_remember(keys); rb_gc_writebarrier_remember(keys);
RARRAY_PTR_USE(keys, ptr, { RARRAY_PTR_USE(keys, ptr, {
size = linear_keys(hash, ptr, size); size = linear_keys(hash, ptr, size);
}); });
} }
else if (RHASH_TABLE_P(hash)) { else if (RHASH_TABLE_P(hash)) {
st_table *table = RHASH_ST_TABLE(hash); st_table *table = RHASH_ST_TABLE(hash);
rb_gc_writebarrier_remember(keys); rb_gc_writebarrier_remember(keys);
RARRAY_PTR_USE(keys, ptr, { RARRAY_PTR_USE(keys, ptr, {
size = st_keys(table, ptr, size); size = st_keys(table, ptr, size);
}); });
} }
rb_ary_set_len(keys, size); rb_ary_set_len(keys, size);
} }
else { else {
@ -3148,20 +3148,20 @@ rb_hash_values(VALUE hash)
if (size == 0) return values; if (size == 0) return values;
if (ST_DATA_COMPATIBLE_P(VALUE)) { if (ST_DATA_COMPATIBLE_P(VALUE)) {
if (RHASH_ARRAY_P(hash)) { if (RHASH_ARRAY_P(hash)) {
rb_gc_writebarrier_remember(values); rb_gc_writebarrier_remember(values);
RARRAY_PTR_USE(values, ptr, { RARRAY_PTR_USE(values, ptr, {
size = linear_values(hash, ptr, size); size = linear_values(hash, ptr, size);
}); });
} }
else if (RHASH_TABLE_P(hash)) { else if (RHASH_TABLE_P(hash)) {
st_table *table = RHASH_ST_TABLE(hash); st_table *table = RHASH_ST_TABLE(hash);
rb_gc_writebarrier_remember(values); rb_gc_writebarrier_remember(values);
RARRAY_PTR_USE(values, ptr, { RARRAY_PTR_USE(values, ptr, {
size = st_values(table, ptr, size); size = st_values(table, ptr, size);
}); });
} }
rb_ary_set_len(values, size); rb_ary_set_len(values, size);
} }
else { else {
@ -3255,8 +3255,8 @@ eql_i(VALUE key, VALUE val1, VALUE arg)
return ST_STOP; return ST_STOP;
} }
else if (RHASH_TABLE_P(data->hash) && !st_lookup(RHASH_ST_TABLE(data->hash), key, &val2)) { else if (RHASH_TABLE_P(data->hash) && !st_lookup(RHASH_ST_TABLE(data->hash), key, &val2)) {
data->result = Qfalse; data->result = Qfalse;
return ST_STOP; return ST_STOP;
} }
if (!(data->eql ? rb_eql(val1, (VALUE)val2) : (int)rb_equal(val1, (VALUE)val2))) { if (!(data->eql ? rb_eql(val1, (VALUE)val2) : (int)rb_equal(val1, (VALUE)val2))) {
@ -3304,14 +3304,14 @@ hash_equal(VALUE hash1, VALUE hash2, int eql)
if (RHASH_SIZE(hash1) != RHASH_SIZE(hash2)) if (RHASH_SIZE(hash1) != RHASH_SIZE(hash2))
return Qfalse; return Qfalse;
if (!RHASH_TABLE_EMPTY(hash1) && !RHASH_TABLE_EMPTY(hash2)) { if (!RHASH_TABLE_EMPTY(hash1) && !RHASH_TABLE_EMPTY(hash2)) {
if (RHASH_TYPE(hash1) != RHASH_TYPE(hash2)) if (RHASH_TYPE(hash1) != RHASH_TYPE(hash2))
return Qfalse; return Qfalse;
data.hash = hash2; data.hash = hash2;
data.eql = eql; data.eql = eql;
return rb_exec_recursive_paired(recursive_eql, hash1, hash2, (VALUE)&data); return rb_exec_recursive_paired(recursive_eql, hash1, hash2, (VALUE)&data);
} }
#if 0 #if 0
if (!(rb_equal(RHASH_IFNONE(hash1), RHASH_IFNONE(hash2)) && if (!(rb_equal(RHASH_IFNONE(hash1), RHASH_IFNONE(hash2)) &&
FL_TEST(hash1, HASH_PROC_DEFAULT) == FL_TEST(hash2, HASH_PROC_DEFAULT))) FL_TEST(hash1, HASH_PROC_DEFAULT) == FL_TEST(hash2, HASH_PROC_DEFAULT)))
@ -3896,7 +3896,7 @@ rb_hash_compact_bang(VALUE hash)
n = RHASH_SIZE(hash); n = RHASH_SIZE(hash);
if (n) { if (n) {
rb_hash_foreach(hash, delete_if_nil, hash); rb_hash_foreach(hash, delete_if_nil, hash);
if (n != RHASH_SIZE(hash)) if (n != RHASH_SIZE(hash))
return hash; return hash;
} }
return Qnil; return Qnil;
@ -4237,9 +4237,9 @@ rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val) //TODO
if (RHASH_ARRAY_P(hash)) { if (RHASH_ARRAY_P(hash)) {
hash_ltbl(hash); hash_ltbl(hash);
ret = linear_update(hash, (st_data_t)key, add_new_i, (st_data_t)args); ret = linear_update(hash, (st_data_t)key, add_new_i, (st_data_t)args);
if (ret != -1) { if (ret != -1) {
return ret; return ret;
} }
linear_try_convert_table(hash); linear_try_convert_table(hash);
} }
@ -4260,11 +4260,11 @@ linear_bulk_insert(VALUE hash, long argc, const VALUE *argv)
{ {
long i; long i;
for (i = 0; i < argc; ) { for (i = 0; i < argc; ) {
st_data_t k = key_stringify(argv[i++]); st_data_t k = key_stringify(argv[i++]);
st_data_t v = argv[i++]; st_data_t v = argv[i++];
linear_insert(hash, k, v); linear_insert(hash, k, v);
RB_OBJ_WRITTEN(hash, Qundef, k); RB_OBJ_WRITTEN(hash, Qundef, k);
RB_OBJ_WRITTEN(hash, Qundef, v); RB_OBJ_WRITTEN(hash, Qundef, v);
} }
} }
@ -4278,15 +4278,15 @@ rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash)
return; return;
size = argc / 2; size = argc / 2;
if (RHASH_TABLE_EMPTY(hash)) { if (RHASH_TABLE_EMPTY(hash)) {
if (size <= RHASH_ARRAY_MAX_SIZE) if (size <= RHASH_ARRAY_MAX_SIZE)
hash_ltbl(hash); hash_ltbl(hash);
else else
RHASH_TBL_RAW(hash); RHASH_TBL_RAW(hash);
} }
if (RHASH_ARRAY_P(hash) && if (RHASH_ARRAY_P(hash) &&
(RHASH_ARRAY_SIZE(hash) + size <= RHASH_ARRAY_MAX_SIZE)) { (RHASH_ARRAY_SIZE(hash) + size <= RHASH_ARRAY_MAX_SIZE)) {
linear_bulk_insert(hash, argc, argv); linear_bulk_insert(hash, argc, argv);
return; return;
} }
rb_hash_bulk_insert_into_st_table(argc, argv, hash); rb_hash_bulk_insert_into_st_table(argc, argv, hash);

View file

@ -740,8 +740,8 @@ typedef struct li_table {
struct RHash { struct RHash {
struct RBasic basic; struct RBasic basic;
union { union {
struct st_table *st; struct st_table *st;
struct li_table *li; /* possibly 0 */ struct li_table *li; /* possibly 0 */
} as; } as;
int iter_lev; int iter_lev;
const VALUE ifnone; const VALUE ifnone;

View file

@ -887,7 +887,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
else { else {
w_byte(TYPE_HASH_DEF, arg); w_byte(TYPE_HASH_DEF, arg);
} }
w_long(rb_hash_size_num(obj), arg); w_long(rb_hash_size_num(obj), arg);
rb_hash_foreach(obj, hash_each, (st_data_t)&c_arg); rb_hash_foreach(obj, hash_each, (st_data_t)&c_arg);
if (!NIL_P(RHASH_IFNONE(obj))) { if (!NIL_P(RHASH_IFNONE(obj))) {
w_object(RHASH_IFNONE(obj), arg, limit); w_object(RHASH_IFNONE(obj), arg, limit);

View file

@ -569,12 +569,12 @@ transient_heap_ptr(VALUE obj, int error)
case T_HASH: case T_HASH:
if (RHASH_TRANSIENT_P(obj)) { if (RHASH_TRANSIENT_P(obj)) {
TH_ASSERT(RHASH_ARRAY_P(obj)); TH_ASSERT(RHASH_ARRAY_P(obj));
ptr = (VALUE *)(RHASH(obj)->as.li); ptr = (VALUE *)(RHASH(obj)->as.li);
} }
else { else {
ptr = NULL; ptr = NULL;
} }
break; break;
default: default:
if (error) { if (error) {
rb_bug("transient_heap_ptr: unknown obj %s\n", rb_obj_info(obj)); rb_bug("transient_heap_ptr: unknown obj %s\n", rb_obj_info(obj));
@ -666,8 +666,8 @@ transient_heap_block_evacuate(struct transient_heap* theap, struct transient_hea
while (marked_index >= 0) { while (marked_index >= 0) {
struct transient_alloc_header *header = alloc_header(block, marked_index); struct transient_alloc_header *header = alloc_header(block, marked_index);
VALUE obj = header->obj; VALUE obj = header->obj;
TH_ASSERT(header->magic == TRANSIENT_HEAP_ALLOC_MAGIC); TH_ASSERT(header->magic == TRANSIENT_HEAP_ALLOC_MAGIC);
if (header->magic != TRANSIENT_HEAP_ALLOC_MAGIC) rb_bug("rb_transient_heap_mark: wrong header %s\n", rb_obj_info(obj)); if (header->magic != TRANSIENT_HEAP_ALLOC_MAGIC) rb_bug("rb_transient_heap_mark: wrong header %s\n", rb_obj_info(obj));
if (TRANSIENT_HEAP_DEBUG >= 3) fprintf(stderr, " * transient_heap_block_evacuate %p %s\n", header, rb_obj_info(obj)); if (TRANSIENT_HEAP_DEBUG >= 3) fprintf(stderr, " * transient_heap_block_evacuate %p %s\n", header, rb_obj_info(obj));

View file

@ -3327,7 +3327,7 @@ vm_case_dispatch(CDHASH hash, OFFSET else_offset, VALUE key)
key = FIXABLE(kval) ? LONG2FIX((long)kval) : rb_dbl2big(kval); key = FIXABLE(kval) ? LONG2FIX((long)kval) : rb_dbl2big(kval);
} }
} }
if (rb_hash_stlike_lookup(hash, key, &val)) { if (rb_hash_stlike_lookup(hash, key, &val)) {
return FIX2LONG((VALUE)val); return FIX2LONG((VALUE)val);
} }
else { else {