summaryrefslogtreecommitdiff
path: root/internal.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2019-08-01 16:04:40 +0900
committerKoichi Sasada <ko1@atdot.net>2019-08-01 16:06:43 +0900
commit3a6f51ee35da5d49973aba8f7d8128a65a9d8c4a (patch)
tree54bf4d2fc854759ffe09a04b8e01f24e015cd056 /internal.h
parente18e7852536a42434b7b25fa08846fe161290d46 (diff)
introduce ar_hint_t.
Hash hint for ar_array is 1 byte (unsigned char). This patch introduce ar_hint_t which represents hint type.
Diffstat (limited to 'internal.h')
-rw-r--r--internal.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal.h b/internal.h
index 832428bd03..fac8ece2a5 100644
--- a/internal.h
+++ b/internal.h
@@ -817,7 +817,7 @@ struct RComplex {
enum ruby_rhash_flags {
RHASH_PROC_DEFAULT = FL_USER2, /* FL 2 */
RHASH_ST_TABLE_FLAG = FL_USER3, /* FL 3 */
- RHASH_AR_TABLE_MAX_SIZE = 8,
+#define RHASH_AR_TABLE_MAX_SIZE SIZEOF_VALUE
RHASH_AR_TABLE_SIZE_MASK = (FL_USER4|FL_USER5|FL_USER6|FL_USER7), /* FL 4..7 */
RHASH_AR_TABLE_SIZE_SHIFT = (FL_USHIFT+4),
RHASH_AR_TABLE_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11), /* FL 8..11 */
@@ -875,6 +875,14 @@ void rb_hash_st_table_set(VALUE hash, st_table *st);
#define RHASH_UNSET_TRANSIENT_FLAG(h) ((void)0)
#endif
+#if SIZEOF_VALUE / RHASH_AR_TABLE_MAX_SIZE == 2
+typedef uint16_t ar_hint_t;
+#elif SIZEOF_VALUE / RHASH_AR_TABLE_MAX_SIZE == 1
+typedef unsigned char ar_hint_t;
+#else
+#error unsupported
+#endif
+
struct RHash {
struct RBasic basic;
union {
@@ -883,7 +891,7 @@ struct RHash {
} as;
const VALUE ifnone;
union {
- unsigned char ary[sizeof(VALUE)];
+ ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
VALUE word;
} ar_hint;
};