mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rename li_table->ar_table (and related names).
* internal.h: rename the following names: * li_table -> ar_table. "li" means linear (from linear search), but we use the word "array" (from data layout). * RHASH_ARRAY -> RHASH_AR_TABLE. AR_TABLE is more clear. * rb_hash_array_* -> rb_hash_ar_table_*. * RHASH_TABLE_P() -> RHASH_ST_TABLE_P(). more clear. * RHASH_CLEAR() -> RHASH_ST_CLEAR(). * hash.c: rename "linear_" prefix functions to "ar_" prefix. * hash.c (linear_init_table): rename to ar_alloc_table. * debug_counter.h: rename obj_hash_array to obj_hash_ar. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bd78a07f46
commit
e4c79d0d10
6 changed files with 332 additions and 331 deletions
4
array.c
4
array.c
|
@ -4431,10 +4431,10 @@ static inline void
|
|||
ary_recycle_hash(VALUE hash)
|
||||
{
|
||||
assert(RBASIC_CLASS(hash) == 0);
|
||||
if (RHASH_TABLE_P(hash)) {
|
||||
if (RHASH_ST_TABLE_P(hash)) {
|
||||
st_table *tbl = RHASH_ST_TABLE(hash);
|
||||
st_free_table(tbl);
|
||||
RHASH_CLEAR(hash);
|
||||
RHASH_ST_CLEAR(hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ RB_DEBUG_COUNTER(obj_hash_empty)
|
|||
RB_DEBUG_COUNTER(obj_hash_under4)
|
||||
RB_DEBUG_COUNTER(obj_hash_ge4)
|
||||
RB_DEBUG_COUNTER(obj_hash_ge8)
|
||||
RB_DEBUG_COUNTER(obj_hash_array)
|
||||
RB_DEBUG_COUNTER(obj_hash_ar)
|
||||
RB_DEBUG_COUNTER(obj_hash_st)
|
||||
RB_DEBUG_COUNTER(obj_hash_transient)
|
||||
|
||||
|
|
20
gc.c
20
gc.c
|
@ -2271,15 +2271,15 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
|
|||
RB_DEBUG_COUNTER_INC(obj_hash_empty);
|
||||
}
|
||||
|
||||
if (RHASH_ARRAY_P(obj)) {
|
||||
RB_DEBUG_COUNTER_INC(obj_hash_array);
|
||||
if (RHASH_AR_TABLE_P(obj)) {
|
||||
RB_DEBUG_COUNTER_INC(obj_hash_ar);
|
||||
}
|
||||
else {
|
||||
RB_DEBUG_COUNTER_INC(obj_hash_st);
|
||||
}
|
||||
#endif
|
||||
if (/* RHASH_ARRAY_P(obj) */ !FL_TEST_RAW(obj, RHASH_ST_TABLE_FLAG)) {
|
||||
li_table *tab = RHASH(obj)->as.li;
|
||||
if (/* RHASH_AR_TABLE_P(obj) */ !FL_TEST_RAW(obj, RHASH_ST_TABLE_FLAG)) {
|
||||
ar_table *tab = RHASH(obj)->as.ar;
|
||||
|
||||
if (tab) {
|
||||
if (RHASH_TRANSIENT_P(obj)) {
|
||||
|
@ -2291,7 +2291,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
|
|||
}
|
||||
}
|
||||
else {
|
||||
GC_ASSERT(RHASH_TABLE_P(obj));
|
||||
GC_ASSERT(RHASH_ST_TABLE_P(obj));
|
||||
st_free_table(RHASH(obj)->as.st);
|
||||
}
|
||||
break;
|
||||
|
@ -3355,8 +3355,8 @@ obj_memsize_of(VALUE obj, int use_all_types)
|
|||
size += rb_ary_memsize(obj);
|
||||
break;
|
||||
case T_HASH:
|
||||
if (RHASH_ARRAY_P(obj)) {
|
||||
size += sizeof(li_table);
|
||||
if (RHASH_AR_TABLE_P(obj)) {
|
||||
size += sizeof(ar_table);
|
||||
}
|
||||
else {
|
||||
VM_ASSERT(RHASH_ST_TABLE(obj) != NULL);
|
||||
|
@ -4254,9 +4254,9 @@ mark_hash(rb_objspace_t *objspace, VALUE hash)
|
|||
{
|
||||
rb_hash_stlike_foreach(hash, mark_keyvalue, (st_data_t)objspace);
|
||||
|
||||
if (RHASH_ARRAY_P(hash)) {
|
||||
if (RHASH_AR_TABLE_P(hash)) {
|
||||
if (objspace->mark_func_data == NULL && RHASH_TRANSIENT_P(hash)) {
|
||||
rb_transient_heap_mark(hash, RHASH_ARRAY(hash));
|
||||
rb_transient_heap_mark(hash, RHASH_AR_TABLE(hash));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -9710,7 +9710,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
|
|||
}
|
||||
case T_HASH: {
|
||||
snprintf(buff, buff_size, "%s [%c%c] %d", buff,
|
||||
RHASH_ARRAY_P(obj) ? 'A' : 'S',
|
||||
RHASH_AR_TABLE_P(obj) ? 'A' : 'S',
|
||||
RHASH_TRANSIENT_P(obj) ? 'T' : ' ',
|
||||
(int)RHASH_SIZE(obj));
|
||||
break;
|
||||
|
|
68
internal.h
68
internal.h
|
@ -760,44 +760,44 @@ struct RComplex {
|
|||
|
||||
enum ruby_rhash_flags {
|
||||
RHASH_ST_TABLE_FLAG = FL_USER3,
|
||||
RHASH_ARRAY_MAX_SIZE = 8,
|
||||
RHASH_ARRAY_SIZE_MASK = (FL_USER4|FL_USER5|FL_USER6|FL_USER7),
|
||||
RHASH_ARRAY_SIZE_SHIFT = (FL_USHIFT+4),
|
||||
RHASH_ARRAY_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11),
|
||||
RHASH_ARRAY_BOUND_SHIFT = (FL_USHIFT+8),
|
||||
RHASH_AR_TABLE_MAX_SIZE = 8,
|
||||
RHASH_AR_TABLE_SIZE_MASK = (FL_USER4|FL_USER5|FL_USER6|FL_USER7),
|
||||
RHASH_AR_TABLE_SIZE_SHIFT = (FL_USHIFT+4),
|
||||
RHASH_AR_TABLE_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11),
|
||||
RHASH_AR_TABLE_BOUND_SHIFT = (FL_USHIFT+8),
|
||||
|
||||
RHASH_ENUM_END
|
||||
};
|
||||
|
||||
#define HASH_PROC_DEFAULT FL_USER2
|
||||
|
||||
#define RHASH_ARRAY_SIZE_RAW(h) \
|
||||
((unsigned int)((RBASIC(h)->flags & RHASH_ARRAY_SIZE_MASK) >> RHASH_ARRAY_SIZE_SHIFT))
|
||||
#define RHASH_AR_TABLE_SIZE_RAW(h) \
|
||||
((unsigned int)((RBASIC(h)->flags & RHASH_AR_TABLE_SIZE_MASK) >> RHASH_AR_TABLE_SIZE_SHIFT))
|
||||
|
||||
int rb_hash_array_p(VALUE hash);
|
||||
struct li_table *rb_hash_array(VALUE hash);
|
||||
int rb_hash_ar_table_p(VALUE hash);
|
||||
struct ar_table_struct *rb_hash_ar_table(VALUE hash);
|
||||
st_table *rb_hash_st_table(VALUE hash);
|
||||
void rb_hash_st_table_set(VALUE hash, st_table *st);
|
||||
|
||||
#if 0 /* for debug */
|
||||
#define RHASH_ARRAY_P(hash) rb_hash_array_p(hash)
|
||||
#define RHASH_ARRAY(h) rb_hash_array(h)
|
||||
#define RHASH_AR_TABLE_P(hash) rb_hash_ar_table_p(hash)
|
||||
#define RHASH_AR_TABLE(h) rb_hash_ar_table(h)
|
||||
#define RHASH_ST_TABLE(h) rb_hash_st_table(h)
|
||||
#else
|
||||
#define RHASH_ARRAY_P(hash) (!FL_TEST_RAW((hash), RHASH_ST_TABLE_FLAG))
|
||||
#define RHASH_ARRAY(hash) (RHASH(hash)->as.li)
|
||||
#define RHASH_AR_TABLE_P(hash) (!FL_TEST_RAW((hash), RHASH_ST_TABLE_FLAG))
|
||||
#define RHASH_AR_TABLE(hash) (RHASH(hash)->as.ar)
|
||||
#define RHASH_ST_TABLE(hash) (RHASH(hash)->as.st)
|
||||
#endif
|
||||
|
||||
#define RHASH(obj) (R_CAST(RHash)(obj))
|
||||
#define RHASH_ST_SIZE(h) (RHASH_ST_TABLE(h)->num_entries)
|
||||
#define RHASH_TABLE_P(h) (!RHASH_ARRAY_P(h))
|
||||
#define RHASH_CLEAR(h) (FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG), RHASH(h)->as.li = NULL)
|
||||
#define RHASH_ST_TABLE_P(h) (!RHASH_AR_TABLE_P(h))
|
||||
#define RHASH_ST_CLEAR(h) (FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG), RHASH(h)->as.ar = NULL)
|
||||
|
||||
#define RHASH_ARRAY_SIZE_MASK (VALUE)RHASH_ARRAY_SIZE_MASK
|
||||
#define RHASH_ARRAY_SIZE_SHIFT RHASH_ARRAY_SIZE_SHIFT
|
||||
#define RHASH_ARRAY_BOUND_MASK (VALUE)RHASH_ARRAY_BOUND_MASK
|
||||
#define RHASH_ARRAY_BOUND_SHIFT RHASH_ARRAY_BOUND_SHIFT
|
||||
#define RHASH_AR_TABLE_SIZE_MASK (VALUE)RHASH_AR_TABLE_SIZE_MASK
|
||||
#define RHASH_AR_TABLE_SIZE_SHIFT RHASH_AR_TABLE_SIZE_SHIFT
|
||||
#define RHASH_AR_TABLE_BOUND_MASK (VALUE)RHASH_AR_TABLE_BOUND_MASK
|
||||
#define RHASH_AR_TABLE_BOUND_SHIFT RHASH_AR_TABLE_BOUND_SHIFT
|
||||
|
||||
#if USE_TRANSIENT_HEAP
|
||||
#define RHASH_TRANSIENT_FLAG FL_USER14
|
||||
|
@ -810,33 +810,33 @@ void rb_hash_st_table_set(VALUE hash, st_table *st);
|
|||
#define RHASH_UNSET_TRANSIENT_FLAG(h) ((void)0)
|
||||
#endif
|
||||
|
||||
#define RHASH_ARRAY_MAX_SIZE 8
|
||||
#define RHASH_ARRAY_MAX_BOUND RHASH_ARRAY_MAX_SIZE
|
||||
#define RHASH_AR_TABLE_MAX_SIZE 8
|
||||
#define RHASH_AR_TABLE_MAX_BOUND RHASH_AR_TABLE_MAX_SIZE
|
||||
|
||||
typedef struct li_table_entry {
|
||||
typedef struct ar_table_entry {
|
||||
VALUE hash;
|
||||
VALUE key;
|
||||
VALUE record;
|
||||
} li_table_entry;
|
||||
} ar_table_entry;
|
||||
|
||||
typedef struct li_table {
|
||||
li_table_entry entries[RHASH_ARRAY_MAX_SIZE];
|
||||
} li_table;
|
||||
typedef struct ar_table_struct {
|
||||
ar_table_entry entries[RHASH_AR_TABLE_MAX_SIZE];
|
||||
} ar_table;
|
||||
|
||||
/*
|
||||
* RHASH_ARRAY_P(h):
|
||||
* * as.li == NULL or
|
||||
* as.li points li_table.
|
||||
* * as.li is allocated by transient heap or xmalloc.
|
||||
* RHASH_AR_TABLE_P(h):
|
||||
* * as.ar == NULL or
|
||||
* as.ar points ar_table.
|
||||
* * as.ar is allocated by transient heap or xmalloc.
|
||||
*
|
||||
* !RHASH_ARRAY_P(h):
|
||||
* !RHASH_AR_TABLE_P(h):
|
||||
* * as.st points st_table.
|
||||
*/
|
||||
struct RHash {
|
||||
struct RBasic basic;
|
||||
union {
|
||||
struct st_table *st;
|
||||
struct li_table *li; /* possibly 0 */
|
||||
st_table *st;
|
||||
ar_table *ar; /* possibly 0 */
|
||||
} as;
|
||||
int iter_lev;
|
||||
const VALUE ifnone;
|
||||
|
@ -849,7 +849,7 @@ struct RHash {
|
|||
|
||||
# define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
|
||||
# define RHASH_IFNONE(h) (RHASH(h)->ifnone)
|
||||
# define RHASH_SIZE(h) (RHASH_ARRAY_P(h) ? RHASH_ARRAY_SIZE_RAW(h) : RHASH_ST_SIZE(h))
|
||||
# define RHASH_SIZE(h) (RHASH_AR_TABLE_P(h) ? RHASH_AR_TABLE_SIZE_RAW(h) : RHASH_ST_SIZE(h))
|
||||
#endif /* #ifdef RHASH_ITER_LEV */
|
||||
|
||||
/* missing/setproctitle.c */
|
||||
|
|
|
@ -583,8 +583,8 @@ transient_heap_ptr(VALUE obj, int error)
|
|||
break;
|
||||
case T_HASH:
|
||||
if (RHASH_TRANSIENT_P(obj)) {
|
||||
TH_ASSERT(RHASH_ARRAY_P(obj));
|
||||
ptr = (VALUE *)(RHASH(obj)->as.li);
|
||||
TH_ASSERT(RHASH_AR_TABLE_P(obj));
|
||||
ptr = (VALUE *)(RHASH(obj)->as.ar);
|
||||
}
|
||||
else {
|
||||
ptr = NULL;
|
||||
|
|
Loading…
Reference in a new issue