mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
hide ar_table internals from internal.h.
* internal.h: move ar_table def to hash.c because other files don't need to know implementation of ar_table. * hash.c (rb_hash_ar_table_size): added because gc.c needs to know the size_of(ar_table). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9f3585afad
commit
8ee0a8e91a
3 changed files with 33 additions and 25 deletions
5
gc.c
5
gc.c
|
@ -2279,7 +2279,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (/* RHASH_AR_TABLE_P(obj) */ !FL_TEST_RAW(obj, RHASH_ST_TABLE_FLAG)) {
|
if (/* RHASH_AR_TABLE_P(obj) */ !FL_TEST_RAW(obj, RHASH_ST_TABLE_FLAG)) {
|
||||||
ar_table *tab = RHASH(obj)->as.ar;
|
struct ar_table_struct *tab = RHASH(obj)->as.ar;
|
||||||
|
|
||||||
if (tab) {
|
if (tab) {
|
||||||
if (RHASH_TRANSIENT_P(obj)) {
|
if (RHASH_TRANSIENT_P(obj)) {
|
||||||
|
@ -3356,7 +3356,8 @@ obj_memsize_of(VALUE obj, int use_all_types)
|
||||||
break;
|
break;
|
||||||
case T_HASH:
|
case T_HASH:
|
||||||
if (RHASH_AR_TABLE_P(obj)) {
|
if (RHASH_AR_TABLE_P(obj)) {
|
||||||
size += sizeof(ar_table);
|
size_t rb_hash_ar_table_size();
|
||||||
|
size += rb_hash_ar_table_size();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VM_ASSERT(RHASH_ST_TABLE(obj) != NULL);
|
VM_ASSERT(RHASH_ST_TABLE(obj) != NULL);
|
||||||
|
|
29
hash.c
29
hash.c
|
@ -48,6 +48,35 @@
|
||||||
|
|
||||||
#define COPY_DEFAULT(hash, hash2) copy_default(RHASH(hash), RHASH(hash2))
|
#define COPY_DEFAULT(hash, hash2) copy_default(RHASH(hash), RHASH(hash2))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* RHASH_AR_TABLE_P(h):
|
||||||
|
* * as.ar == NULL or
|
||||||
|
* as.ar points ar_table.
|
||||||
|
* * as.ar is allocated by transient heap or xmalloc.
|
||||||
|
*
|
||||||
|
* !RHASH_AR_TABLE_P(h):
|
||||||
|
* * as.st points st_table.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define RHASH_AR_TABLE_MAX_SIZE 8
|
||||||
|
#define RHASH_AR_TABLE_MAX_BOUND RHASH_AR_TABLE_MAX_SIZE
|
||||||
|
|
||||||
|
typedef struct ar_table_entry {
|
||||||
|
VALUE hash;
|
||||||
|
VALUE key;
|
||||||
|
VALUE record;
|
||||||
|
} ar_table_entry;
|
||||||
|
|
||||||
|
typedef struct ar_table_struct {
|
||||||
|
ar_table_entry entries[RHASH_AR_TABLE_MAX_SIZE];
|
||||||
|
} ar_table;
|
||||||
|
|
||||||
|
size_t
|
||||||
|
rb_hash_ar_table_size(void)
|
||||||
|
{
|
||||||
|
return sizeof(ar_table);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
copy_default(struct RHash *hash, const struct RHash *hash2)
|
copy_default(struct RHash *hash, const struct RHash *hash2)
|
||||||
{
|
{
|
||||||
|
|
24
internal.h
24
internal.h
|
@ -810,33 +810,11 @@ void rb_hash_st_table_set(VALUE hash, st_table *st);
|
||||||
#define RHASH_UNSET_TRANSIENT_FLAG(h) ((void)0)
|
#define RHASH_UNSET_TRANSIENT_FLAG(h) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RHASH_AR_TABLE_MAX_SIZE 8
|
|
||||||
#define RHASH_AR_TABLE_MAX_BOUND RHASH_AR_TABLE_MAX_SIZE
|
|
||||||
|
|
||||||
typedef struct ar_table_entry {
|
|
||||||
VALUE hash;
|
|
||||||
VALUE key;
|
|
||||||
VALUE record;
|
|
||||||
} ar_table_entry;
|
|
||||||
|
|
||||||
typedef struct ar_table_struct {
|
|
||||||
ar_table_entry entries[RHASH_AR_TABLE_MAX_SIZE];
|
|
||||||
} ar_table;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RHASH_AR_TABLE_P(h):
|
|
||||||
* * as.ar == NULL or
|
|
||||||
* as.ar points ar_table.
|
|
||||||
* * as.ar is allocated by transient heap or xmalloc.
|
|
||||||
*
|
|
||||||
* !RHASH_AR_TABLE_P(h):
|
|
||||||
* * as.st points st_table.
|
|
||||||
*/
|
|
||||||
struct RHash {
|
struct RHash {
|
||||||
struct RBasic basic;
|
struct RBasic basic;
|
||||||
union {
|
union {
|
||||||
st_table *st;
|
st_table *st;
|
||||||
ar_table *ar; /* possibly 0 */
|
struct ar_table_struct *ar; /* possibly 0 */
|
||||||
} as;
|
} as;
|
||||||
int iter_lev;
|
int iter_lev;
|
||||||
const VALUE ifnone;
|
const VALUE ifnone;
|
||||||
|
|
Loading…
Reference in a new issue