summaryrefslogtreecommitdiff
path: root/internal/hash.h
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2023-04-19 16:02:36 -0400
committerPeter Zhu <[email protected]>2023-05-17 09:19:40 -0400
commit0938964ba1af3924cf969fb809fc3598892bc20d ()
treec87a84dcbec890a0e35a4a84c96a0892653dbbc0 /internal/hash.h
parent5199f2aaf9527c97e6ec371e19748d0c2ac7a70e (diff)
Implement Hash ST tables on VWA
Notes: Merged: https://.com/ruby/ruby/pull/7742
-rw-r--r--internal/hash.h27
1 files changed, 19 insertions, 8 deletions
@@ -40,6 +40,16 @@ enum ruby_rhash_flags {
RHASH_LEV_MAX = 127, /* 7 bits */
};
struct RHash {
struct RBasic basic;
const VALUE ifnone;
@@ -47,13 +57,16 @@ struct RHash {
ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
VALUE word;
} ar_hint;
- union {
- st_table *st;
- } as;
};
#define RHASH(obj) ((struct RHash *)(obj))
#ifdef RHASH_IFNONE
# undef RHASH_IFNONE
#endif
@@ -85,8 +98,6 @@ int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_fu
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
VALUE rb_ident_hash_new_with_size(st_index_t size);
-size_t rb_hash_size_as_embedded(VALUE hash);
-
static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h);
static inline VALUE RHASH_IFNONE(VALUE h);
static inline size_t RHASH_SIZE(VALUE h);
@@ -126,13 +137,13 @@ RHASH_AR_TABLE_P(VALUE h)
static inline struct ar_table_struct *
RHASH_AR_TABLE(VALUE h)
{
- return (struct ar_table_struct *)((uintptr_t)h + offsetof(struct RHash, as.st));
}
static inline st_table *
RHASH_ST_TABLE(VALUE h)
{
- return RHASH(h)->as.st;
}
static inline VALUE
@@ -173,7 +184,7 @@ RHASH_ST_SIZE(VALUE h)
static inline void
RHASH_ST_CLEAR(VALUE h)
{
- RHASH(h)->as.st = NULL;
FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG);
}