diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-29 16:29:44 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-29 16:29:44 +0000 |
commit | 8ee0a8e91a2dfcde0381949348268961b0f81393 (patch) | |
tree | a7d361acfbdf128d75cb67b8eb42f2f0b49bdfea | |
parent | 9f3585afad86f7683fec377a0eb4bb53b8165529 (diff) | |
download | ruby-8ee0a8e91a2dfcde0381949348268961b0f81393.tar.gz |
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
-rw-r--r-- | gc.c | 5 | ||||
-rw-r--r-- | hash.c | 29 | ||||
-rw-r--r-- | internal.h | 24 |
3 files changed, 33 insertions, 25 deletions
@@ -2279,7 +2279,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj) } #endif 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 (RHASH_TRANSIENT_P(obj)) { @@ -3356,7 +3356,8 @@ obj_memsize_of(VALUE obj, int use_all_types) break; case T_HASH: if (RHASH_AR_TABLE_P(obj)) { - size += sizeof(ar_table); + size_t rb_hash_ar_table_size(); + size += rb_hash_ar_table_size(); } else { VM_ASSERT(RHASH_ST_TABLE(obj) != NULL); @@ -48,6 +48,35 @@ #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 copy_default(struct RHash *hash, const struct RHash *hash2) { diff --git a/internal.h b/internal.h index 433ab6635d..9d90c191f2 100644 --- a/internal.h +++ b/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) #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 RBasic basic; union { st_table *st; - ar_table *ar; /* possibly 0 */ + struct ar_table_struct *ar; /* possibly 0 */ } as; int iter_lev; const VALUE ifnone; |