ruby-changes:54423
From: ko1 <ko1@a...>
Date: Sun, 30 Dec 2018 01:29:51 +0900 (JST)
Subject: [ruby-changes:54423] ko1:r66638 (trunk): hide ar_table internals from internal.h.
ko1 2018-12-30 01:29:44 +0900 (Sun, 30 Dec 2018) New Revision: 66638 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66638 Log: 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). Modified files: trunk/gc.c trunk/hash.c trunk/internal.h Index: gc.c =================================================================== --- gc.c (revision 66637) +++ gc.c (revision 66638) @@ -2279,7 +2279,7 @@ obj_free(rb_objspace_t *objspace, VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L2279 } #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_ty https://github.com/ruby/ruby/blob/trunk/gc.c#L3356 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); Index: hash.c =================================================================== --- hash.c (revision 66637) +++ hash.c (revision 66638) @@ -48,6 +48,35 @@ https://github.com/ruby/ruby/blob/trunk/hash.c#L48 #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) { Index: internal.h =================================================================== --- internal.h (revision 66637) +++ internal.h (revision 66638) @@ -810,33 +810,11 @@ void rb_hash_st_table_set(VALUE hash, st https://github.com/ruby/ruby/blob/trunk/internal.h#L810 #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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/