summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-29 16:29:44 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-29 16:29:44 +0000
commit8ee0a8e91a2dfcde0381949348268961b0f81393 (patch)
treea7d361acfbdf128d75cb67b8eb42f2f0b49bdfea /hash.c
parent9f3585afad86f7683fec377a0eb4bb53b8165529 (diff)
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
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index 3bba88adc7..870511a577 100644
--- a/hash.c
+++ b/hash.c
@@ -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)
{