w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

hash.c File Reference
#include <string.h>
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/class.h>
#include <mruby/hash.h>
#include <mruby/variable.h>
#include <mruby/presym.h>
Include dependency graph for hash.c:

Go to the source code of this file.

Classes

struct  _mrb_static_assert___LINE__
 
struct  hash_entry
 
struct  hash_table
 
struct  index_buckets_iter
 

Macros

#define EA_N_RESERVED_INDICES   2 /* empty and deleted */
 
#define EA_INCREASE_RATIO   6 / 5 + 6
 
#define EA_MAX_INCREASE   UINT16_MAX
 
#define EA_MAX_CAPA   U32(lesser(IB_MAX_CAPA - EA_N_RESERVED_INDICES, MRB_INT_MAX))
 
#define IB_MAX_CAPA   (U32(1) << IB_MAX_BIT)
 
#define IB_TYPE_BIT   32
 
#define IB_INIT_BIT
 
#define IB_MAX_BIT   (IB_TYPE_BIT - 1)
 
#define AR_DEFAULT_CAPA   4
 
#define AR_MAX_SIZE   16
 
#define H_MAX_SIZE   EA_MAX_CAPA
 
#define DEFINE_GETTER(c_, n_, t_, p_)    MRB_INLINE t_ c_##_##n_(const struct RHash *h) {return h->p_;}
 
#define DEFINE_SETTER(c_, n_, t_, p_)    MRB_INLINE void c_##_set_##n_(struct RHash *h, t_ v) {h->p_ = v;}
 
#define DEFINE_ACCESSOR(c_, n_, t_, p_)
 
#define DEFINE_FLAG_GETTER(c_, n_, t_, k_)
 
#define DEFINE_FLAG_SETTER(c_, n_, t_, k_)
 
#define DEFINE_FLAG_ACCESSOR(c_, n_, t_, k_)
 
#define DEFINE_INCREMENTER(c_, n_)
 
#define DEFINE_DECREMENTER(c_, n_)
 
#define DEFINE_SWITCHER(n_, k_)
 
#define ea_each_used(ea, n_used, entry_var, code)
 
#define ea_each(ea, size, entry_var, code)
 
#define ib_cycle_by_key(mrb, h, key, it_var, code)
 
#define ib_find_by_key(mrb, h_, key_, it_var, code)
 
#define h_each(h, entry_var, code)
 
#define HT_ASSERT_SAFE_READ(attr_name)
 
#define h_check_modified(mrb, h, code)
 
#define U32(v)   ((uint32_t)(v))
 
#define h_ar_p(h)   (!h_ht_p(h))
 
#define h_ar_on(h)   h_ht_off(h)
 
#define lesser(a, b)   ((a) < (b) ? (a) : (b))
 
#define RHASH_IFNONE(hash)   mrb_iv_get(mrb, (hash), MRB_SYM(ifnone))
 
#define RHASH_PROCDEFAULT(hash)   RHASH_IFNONE(hash)
 

Typedefs

typedef struct hash_entry hash_entry
 
typedef struct hash_table hash_table
 
typedef struct index_buckets_iter index_buckets_iter
 

Functions

static uint32_t ar_ea_capa (const struct RHash *h)
 
static void ar_set_ea_capa (struct RHash *h, uint32_t v)
 
static uint32_t ar_ea_n_used (const struct RHash *h)
 
static void ar_set_ea_n_used (struct RHash *h, uint32_t v)
 
static uint32_t ht_ea_capa (const struct RHash *h)
 
static void ht_set_ea_capa (struct RHash *h, uint32_t v)
 
static uint32_t ht_ea_n_used (const struct RHash *h)
 
static void ht_set_ea_n_used (struct RHash *h, uint32_t v)
 
static uint32_t ib_bit (const struct RHash *h)
 
static void ib_set_bit (struct RHash *h, uint32_t v)
 
static uint32_t ar_size (const struct RHash *h)
 
static void ar_set_size (struct RHash *h, uint32_t v)
 
static hash_entryar_ea (const struct RHash *h)
 
static void ar_set_ea (struct RHash *h, hash_entry *v)
 
static void ar_dec_size (struct RHash *h)
 
static uint32_t ht_size (const struct RHash *h)
 
static void ht_set_size (struct RHash *h, uint32_t v)
 
static hash_entryht_ea (const struct RHash *h)
 
static void ht_set_ea (struct RHash *h, hash_entry *v)
 
static uint32_tht_ib (const struct RHash *h)
 
static void ht_inc_size (struct RHash *h)
 
static void ht_dec_size (struct RHash *h)
 
static uint32_t h_size (const struct RHash *h)
 
static hash_tableh_ht (const struct RHash *h)
 
static void h_set_ht (struct RHash *h, hash_table *v)
 
static void h_ht_on (struct RHash *h)
 
static void h_ht_off (struct RHash *h)
 
static mrb_bool h_ht_p (const struct RHash *h)
 
static uint32_t ib_upper_bound_for (uint32_t capa)
 
static uint32_t ib_bit_to_capa (uint32_t bit)
 
static void ht_init (mrb_state *mrb, struct RHash *h, uint32_t size, hash_entry *ea, uint32_t ea_capa, hash_table *ht, uint32_t ib_bit)
 
static void ht_set_without_ib_adjustment (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value val)
 
static uint32_t next_power2 (uint32_t v)
 
static uint32_t obj_hash_code (mrb_state *mrb, mrb_value key, struct RHash *h)
 
static mrb_bool obj_eql (mrb_state *mrb, mrb_value a, mrb_value b, struct RHash *h)
 
static mrb_bool entry_deleted_p (const hash_entry *entry)
 
static void entry_delete (hash_entry *entry)
 
static uint32_t ea_next_capa_for (uint32_t size, uint32_t max_capa)
 
static hash_entryea_resize (mrb_state *mrb, hash_entry *ea, uint32_t capa)
 
static void ea_compress (hash_entry *ea, uint32_t n_used)
 
static hash_entryea_adjust (mrb_state *mrb, hash_entry *ea, uint32_t *capap, uint32_t max_capa)
 
static hash_entryea_dup (mrb_state *mrb, const hash_entry *ea, uint32_t capa)
 
static hash_entryea_get_by_key (mrb_state *mrb, hash_entry *ea, uint32_t size, mrb_value key, struct RHash *h)
 
static hash_entryea_get (hash_entry *ea, uint32_t index)
 
static void ea_set (hash_entry *ea, uint32_t index, mrb_value key, mrb_value val)
 
static void ar_init (struct RHash *h, uint32_t size, hash_entry *ea, uint32_t ea_capa, uint32_t ea_n_used)
 
static void ar_free (mrb_state *mrb, struct RHash *h)
 
static void ar_adjust_ea (mrb_state *mrb, struct RHash *h, uint32_t size, uint32_t max_ea_capa)
 
static void ar_compress (mrb_state *mrb, struct RHash *h)
 
static mrb_bool ar_get (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value *valp)
 
static void ar_set (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value val)
 
static mrb_bool ar_delete (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value *valp)
 
static void ar_shift (mrb_state *mrb, struct RHash *h, mrb_value *keyp, mrb_value *valp)
 
static void ar_rehash (mrb_state *mrb, struct RHash *h)
 
static uint32_t ib_it_pos_for (index_buckets_iter *it, uint32_t v)
 
static uint32_t ib_it_empty_value (const index_buckets_iter *it)
 
static uint32_t ib_it_deleted_value (const index_buckets_iter *it)
 
static mrb_bool ib_it_empty_p (const index_buckets_iter *it)
 
static mrb_bool ib_it_deleted_p (const index_buckets_iter *it)
 
static mrb_bool ib_it_active_p (const index_buckets_iter *it)
 
static void ib_it_init (mrb_state *mrb, index_buckets_iter *it, struct RHash *h, mrb_value key)
 
static void ib_it_next (index_buckets_iter *it)
 
static uint32_t ib_it_get (const index_buckets_iter *it)
 
static void ib_it_set (index_buckets_iter *it, uint32_t ea_index)
 
static void ib_it_delete (index_buckets_iter *it)
 
static hash_entryib_it_entry (index_buckets_iter *it)
 
static uint32_t ib_capa_to_bit (uint32_t capa)
 
static uint32_t ib_bit_for (uint32_t size)
 
static uint32_t ib_byte_size_for (uint32_t ib_bit)
 
static void ib_init (mrb_state *mrb, struct RHash *h, uint32_t ib_bit, size_t ib_byte_size)
 
static void ht_free (mrb_state *mrb, struct RHash *h)
 
static hash_tableht_dup (mrb_state *mrb, const struct RHash *h)
 
static void ht_adjust_ea (mrb_state *mrb, struct RHash *h, uint32_t size, uint32_t max_ea_capa)
 
static void ht_to_ar (mrb_state *mrb, struct RHash *h)
 
static mrb_bool ht_get (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value *valp)
 
static void ht_set_as_ar (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value val)
 
static void ht_set (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value val)
 
static mrb_bool ht_delete (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value *valp)
 
static void ht_shift (mrb_state *mrb, struct RHash *h, mrb_value *keyp, mrb_value *valp)
 
static void ht_rehash (mrb_state *mrb, struct RHash *h)
 
static mrb_value h_key_for (mrb_state *mrb, mrb_value key)
 
static struct RHashh_alloc (mrb_state *mrb)
 
static void h_init (struct RHash *h)
 
static void h_free_table (mrb_state *mrb, struct RHash *h)
 
static void h_clear (mrb_state *mrb, struct RHash *h)
 
static mrb_bool h_get (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value *valp)
 
static void h_set (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value val)
 
static mrb_bool h_delete (mrb_state *mrb, struct RHash *h, mrb_value key, mrb_value *valp)
 
static void h_shift (mrb_state *mrb, struct RHash *h, mrb_value *keyp, mrb_value *valp)
 
static void h_rehash (mrb_state *mrb, struct RHash *h)
 
static void h_replace (mrb_state *mrb, struct RHash *h, struct RHash *orig_h)
 
void mrb_gc_mark_hash (mrb_state *mrb, struct RHash *h)
 
size_t mrb_gc_mark_hash_size (mrb_state *mrb, struct RHash *h)
 
void mrb_gc_free_hash (mrb_state *mrb, struct RHash *h)
 
size_t mrb_hash_memsize (mrb_value self)
 
void mrb_hash_foreach (mrb_state *mrb, struct RHash *h, mrb_hash_foreach_func *func, void *data)
 
mrb_value mrb_hash_new (mrb_state *mrb)
 
mrb_value mrb_hash_new_capa (mrb_state *mrb, mrb_int capa)
 
static mrb_value mrb_hash_default (mrb_state *mrb, mrb_value hash)
 
static void hash_modify (mrb_state *mrb, mrb_value hash)
 
static mrb_value hash_default (mrb_state *mrb, mrb_value hash, mrb_value key)
 
static void hash_replace (mrb_state *mrb, mrb_value self, mrb_value orig)
 
static mrb_value mrb_hash_init_copy (mrb_state *mrb, mrb_value self)
 
void mrb_hash_check_kdict (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_hash_dup (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_hash_get (mrb_state *mrb, mrb_value hash, mrb_value key)
 
mrb_value mrb_hash_fetch (mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def)
 
void mrb_hash_set (mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val)
 
static mrb_value mrb_hash_init (mrb_state *mrb, mrb_value hash)
 
static mrb_value mrb_hash_aget (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_hash_set_default (mrb_state *mrb, mrb_value hash)
 
static mrb_value mrb_hash_default_proc (mrb_state *mrb, mrb_value hash)
 
static mrb_value mrb_hash_set_default_proc (mrb_state *mrb, mrb_value hash)
 
mrb_value mrb_hash_delete_key (mrb_state *mrb, mrb_value hash, mrb_value key)
 
static mrb_value mrb_hash_delete (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_hash_shift (mrb_state *mrb, mrb_value hash)
 
mrb_value mrb_hash_clear (mrb_state *mrb, mrb_value hash)
 
static mrb_value mrb_hash_aset (mrb_state *mrb, mrb_value self)
 
mrb_int mrb_hash_size (mrb_state *mrb, mrb_value hash)
 
static mrb_value mrb_hash_size_m (mrb_state *mrb, mrb_value self)
 
mrb_bool mrb_hash_empty_p (mrb_state *mrb, mrb_value self)
 
static mrb_value mrb_hash_empty_m (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_hash_keys (mrb_state *mrb, mrb_value hash)
 
mrb_value mrb_hash_values (mrb_state *mrb, mrb_value hash)
 
mrb_bool mrb_hash_key_p (mrb_state *mrb, mrb_value hash, mrb_value key)
 
static mrb_value mrb_hash_has_key (mrb_state *mrb, mrb_value hash)
 
static mrb_value mrb_hash_has_value (mrb_state *mrb, mrb_value hash)
 
void mrb_hash_merge (mrb_state *mrb, mrb_value hash1, mrb_value hash2)
 
static mrb_value mrb_hash_rehash (mrb_state *mrb, mrb_value self)
 
void mrb_init_hash (mrb_state *mrb)
 

Macro Definition Documentation

◆ AR_DEFAULT_CAPA

#define AR_DEFAULT_CAPA   4

Definition at line 68 of file hash.c.

◆ AR_MAX_SIZE

#define AR_MAX_SIZE   16

Definition at line 69 of file hash.c.

◆ DEFINE_ACCESSOR

#define DEFINE_ACCESSOR (   c_,
  n_,
  t_,
  p_ 
)
Value:
DEFINE_GETTER(c_, n_, t_, p_) \
DEFINE_SETTER(c_, n_, t_, p_)
#define DEFINE_GETTER(c_, n_, t_, p_)
Definition: hash.c:108

Definition at line 112 of file hash.c.

◆ DEFINE_DECREMENTER

#define DEFINE_DECREMENTER (   c_,
  n_ 
)
Value:
MRB_INLINE void c_##_dec_##n_(struct RHash *h) { \
c_##_set_##n_(h, c_##_##n_(h) - 1); \
}
int h
Definition: dviconv.c:9
#define _(String)
Definition: ftxerr18.c:64
#define MRB_INLINE
Definition: common.h:62
Definition: hash.h:18

Definition at line 131 of file hash.c.

◆ DEFINE_FLAG_ACCESSOR

#define DEFINE_FLAG_ACCESSOR (   c_,
  n_,
  t_,
  k_ 
)
Value:
DEFINE_FLAG_GETTER(c_, n_, t_, k_) \
DEFINE_FLAG_SETTER(c_, n_, t_, k_)
#define DEFINE_FLAG_GETTER(c_, n_, t_, k_)
Definition: hash.c:115

Definition at line 124 of file hash.c.

◆ DEFINE_FLAG_GETTER

#define DEFINE_FLAG_GETTER (   c_,
  n_,
  t_,
  k_ 
)
Value:
MRB_INLINE t_ c_##_##n_(const struct RHash *h) { \
return (t_)((h->flags & MRB_HASH_##k_##_MASK) >> MRB_HASH_##k_##_SHIFT); \
}

Definition at line 115 of file hash.c.

◆ DEFINE_FLAG_SETTER

#define DEFINE_FLAG_SETTER (   c_,
  n_,
  t_,
  k_ 
)
Value:
MRB_INLINE void c_##_set_##n_(struct RHash *h, t_ v) { \
h->flags &= ~~MRB_HASH_##k_##_MASK; \
h->flags |= v << MRB_HASH_##k_##_SHIFT; \
}
int v
Definition: dviconv.c:10

Definition at line 119 of file hash.c.

◆ DEFINE_GETTER

#define DEFINE_GETTER (   c_,
  n_,
  t_,
  p_ 
)     MRB_INLINE t_ c_##_##n_(const struct RHash *h) {return h->p_;}

Definition at line 108 of file hash.c.

◆ DEFINE_INCREMENTER

#define DEFINE_INCREMENTER (   c_,
  n_ 
)
Value:
MRB_INLINE void c_##_inc_##n_(struct RHash *h) { \
c_##_set_##n_(h, c_##_##n_(h) + 1); \
}

Definition at line 127 of file hash.c.

◆ DEFINE_SETTER

#define DEFINE_SETTER (   c_,
  n_,
  t_,
  p_ 
)     MRB_INLINE void c_##_set_##n_(struct RHash *h, t_ v) {h->p_ = v;}

Definition at line 110 of file hash.c.

◆ DEFINE_SWITCHER

#define DEFINE_SWITCHER (   n_,
  k_ 
)
Value:
MRB_INLINE void h_##n_##_on(struct RHash *h) { \
h->flags |= MRB_HASH_##k_; \
} \
MRB_INLINE void h_##n_##_off(struct RHash *h) { \
h->flags &= ~~MRB_HASH_##k_; \
} \
MRB_INLINE mrb_bool h_##n_##_p(const struct RHash *h) { \
return (h->flags & MRB_HASH_##k_) == MRB_HASH_##k_; \
}

Definition at line 135 of file hash.c.

◆ ea_each

#define ea_each (   ea,
  size,
  entry_var,
  code 
)
Value:
do { \
hash_entry *entry_var = ea; \
uint32_t size__ = size; \
for (; 0 < size__; ++entry_var) { \
if (entry_deleted_p(entry_var)) continue; \
--size__; \
code; \
} \
} while (0)
static int size
Definition: ppmlabel.c:24
static mrb_bool entry_deleted_p(const hash_entry *entry)
Definition: hash.c:347

Definition at line 177 of file hash.c.

◆ ea_each_used

#define ea_each_used (   ea,
  n_used,
  entry_var,
  code 
)
Value:
do { \
hash_entry *entry_var = ea, *ea_end__ = entry_var + (n_used); \
for (; entry_var < ea_end__; ++entry_var) { \
code; \
} \
} while (0)

Definition at line 170 of file hash.c.

◆ EA_INCREASE_RATIO

#define EA_INCREASE_RATIO   6 / 5 + 6

Definition at line 57 of file hash.c.

◆ EA_MAX_CAPA

Definition at line 59 of file hash.c.

◆ EA_MAX_INCREASE

#define EA_MAX_INCREASE   UINT16_MAX

Definition at line 58 of file hash.c.

◆ EA_N_RESERVED_INDICES

#define EA_N_RESERVED_INDICES   2 /* empty and deleted */

Definition at line 56 of file hash.c.

◆ h_ar_on

#define h_ar_on (   h)    h_ht_off(h)

Definition at line 256 of file hash.c.

◆ h_ar_p

#define h_ar_p (   h)    (!h_ht_p(h))

Definition at line 255 of file hash.c.

◆ h_check_modified

#define h_check_modified (   mrb,
  h,
  code 
)
Value:
do { \
struct RHash *h__ = h; \
uint32_t flags = h__->flags & mask; \
void* tbl__ = (mrb_assert(h__->ht), h__->ht); \
uint32_t ht_ea_capa__ = ht_ea_capa(h__); \
hash_entry *ht_ea__ = ht_ea(h__); \
code; \
if (flags != (h__->flags & mask) || \
tbl__ != h__->ht || \
ht_ea_capa__ != ht_ea_capa(h__) || \
ht_ea__ != ht_ea(h__)) { \
mrb_raise(mrb, E_RUNTIME_ERROR, "hash modified"); \
} \
} while (0)
#define mrb_assert(p)
Definition: mruby.h:65
#define E_RUNTIME_ERROR
Definition: mruby.h:1307
#define flags
#define MRB_HASH_AR_EA_CAPA_MASK
Definition: hash.h:223
#define MRB_HASH_HT
Definition: hash.h:227
#define MRB_HASH_IB_BIT_MASK
Definition: hash.h:222
static uint32_t ht_ea_capa(const struct RHash *h)
Definition: hash.c:149
static hash_entry * ht_ea(const struct RHash *h)
Definition: hash.c:162
#define mask(n)
Definition: lbitlib.c:93

Definition at line 238 of file hash.c.

◆ h_each

#define h_each (   h,
  entry_var,
  code 
)
Value:
do { \
struct RHash *h__ = h; \
hash_entry *h_e_ea__; \
uint32_t h_e_size__; \
h_ar_p(h) ? (h_e_ea__ = ar_ea(h__), h_e_size__ = ar_size(h__)) : \
(h_e_ea__ = ht_ea(h__), h_e_size__ = ht_size(h__)); \
ea_each(h_e_ea__, h_e_size__, entry_var, code); \
} while (0)
static uint32_t ar_size(const struct RHash *h)
Definition: hash.c:158
static hash_entry * ar_ea(const struct RHash *h)
Definition: hash.c:159
static uint32_t ht_size(const struct RHash *h)
Definition: hash.c:161
Definition: inftrees.h:24

Definition at line 208 of file hash.c.

◆ H_MAX_SIZE

#define H_MAX_SIZE   EA_MAX_CAPA

Definition at line 70 of file hash.c.

◆ HT_ASSERT_SAFE_READ

#define HT_ASSERT_SAFE_READ (   attr_name)
Value:
offsetof(hash_table, attr_name) + sizeof(((hash_table*)0)->attr_name) <= \
sizeof(hash_entry))
#define mrb_static_assert1(exp)
Definition: mruby.h:89
#define offsetof(T, M)
Definition: dir.c:27
Definition: hash.c:75

Definition at line 229 of file hash.c.

◆ ib_cycle_by_key

#define ib_cycle_by_key (   mrb,
  h,
  key,
  it_var,
  code 
)
Value:
do { \
index_buckets_iter it_var[1]; \
ib_it_init(mrb, it_var, h, key); \
for (;;) { \
ib_it_next(it_var); \
code; \
} \
} while (0)
#define key
Definition: tex2xindy.c:753

Definition at line 187 of file hash.c.

◆ ib_find_by_key

#define ib_find_by_key (   mrb,
  h_,
  key_,
  it_var,
  code 
)
Value:
do { \
mrb_value ib_fbk_key__ = key_; \
ib_cycle_by_key(mrb, h_, ib_fbk_key__, it_var, { \
if (ib_it_empty_p(it_var)) break; \
if (ib_it_deleted_p(it_var)) continue; \
if (obj_eql(mrb, ib_fbk_key__, ib_it_entry(it_var)->key, it_var->h)) { \
code; \
break; \
} \
}); \
} while (0)
static mrb_bool obj_eql(mrb_state *mrb, mrb_value a, mrb_value b, struct RHash *h)
Definition: hash.c:317
static mrb_bool ib_it_deleted_p(const index_buckets_iter *it)
Definition: hash.c:590
static hash_entry * ib_it_entry(index_buckets_iter *it)
Definition: hash.c:678
static mrb_bool ib_it_empty_p(const index_buckets_iter *it)
Definition: hash.c:584

Definition at line 196 of file hash.c.

◆ IB_INIT_BIT

#define IB_INIT_BIT
Value:
( \
ib_upper_bound_for(32) <= AR_MAX_SIZE ? 6 : \
ib_upper_bound_for(16) <= AR_MAX_SIZE ? 5 : \
4 \
)
#define AR_MAX_SIZE
Definition: hash.c:69

Definition at line 62 of file hash.c.

◆ IB_MAX_BIT

#define IB_MAX_BIT   (IB_TYPE_BIT - 1)

Definition at line 67 of file hash.c.

◆ IB_MAX_CAPA

#define IB_MAX_CAPA   (U32(1) << IB_MAX_BIT)

Definition at line 60 of file hash.c.

◆ IB_TYPE_BIT

#define IB_TYPE_BIT   32

Definition at line 61 of file hash.c.

◆ lesser

#define lesser (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 257 of file hash.c.

◆ RHASH_IFNONE

#define RHASH_IFNONE (   hash)    mrb_iv_get(mrb, (hash), MRB_SYM(ifnone))

Definition at line 258 of file hash.c.

◆ RHASH_PROCDEFAULT

#define RHASH_PROCDEFAULT (   hash)    RHASH_IFNONE(hash)

Definition at line 259 of file hash.c.

◆ U32

#define U32 (   v)    ((uint32_t)(v))

Definition at line 254 of file hash.c.

Typedef Documentation

◆ hash_entry

typedef struct hash_entry hash_entry

◆ hash_table

typedef struct hash_table hash_table

◆ index_buckets_iter

Function Documentation

◆ ar_adjust_ea()

static void ar_adjust_ea ( mrb_state mrb,
struct RHash h,
uint32_t  size,
uint32_t  max_ea_capa 
)
static

Definition at line 455 of file hash.c.

References ar_ea(), ar_set_ea(), ar_set_ea_capa(), RHash::ea, ea_adjust(), h, and size.

Referenced by ar_compress(), and ar_set().

◆ ar_compress()

static void ar_compress ( mrb_state mrb,
struct RHash h 
)
static

Definition at line 464 of file hash.c.

References ar_adjust_ea(), ar_ea(), ar_ea_capa(), ar_ea_n_used(), AR_MAX_SIZE, ar_set_ea_n_used(), ar_size(), ea_compress(), h, lesser, and size.

Referenced by ar_set().

◆ ar_dec_size()

static void ar_dec_size ( struct RHash h)
inlinestatic

Definition at line 160 of file hash.c.

Referenced by ar_delete().

◆ ar_delete()

static mrb_bool ar_delete ( mrb_state mrb,
struct RHash h,
mrb_value  key,
mrb_value valp 
)
static

Definition at line 517 of file hash.c.

References ar_dec_size(), ar_ea(), ar_size(), ea_get_by_key(), entry, entry_delete(), FALSE, h, key, and TRUE.

Referenced by h_delete().

◆ ar_ea()

static hash_entry* ar_ea ( const struct RHash h)
inlinestatic

◆ ar_ea_capa()

static uint32_t ar_ea_capa ( const struct RHash h)
inlinestatic

Definition at line 147 of file hash.c.

Referenced by ar_compress(), ar_rehash(), ar_set(), h_replace(), and mrb_hash_memsize().

◆ ar_ea_n_used()

static uint32_t ar_ea_n_used ( const struct RHash h)
inlinestatic

Definition at line 148 of file hash.c.

Referenced by ar_compress(), ar_set(), and h_replace().

◆ ar_free()

static void ar_free ( mrb_state mrb,
struct RHash h 
)
static

Definition at line 449 of file hash.c.

References ar_ea(), h, and mrb_free().

Referenced by h_free_table().

◆ ar_get()

static mrb_bool ar_get ( mrb_state mrb,
struct RHash h,
mrb_value  key,
mrb_value valp 
)
static

Definition at line 473 of file hash.c.

References ar_ea(), ar_size(), ea_each, entry, FALSE, h, key, obj_eql(), and TRUE.

Referenced by h_get().

◆ ar_init()

static void ar_init ( struct RHash h,
uint32_t  size,
hash_entry ea,
uint32_t  ea_capa,
uint32_t  ea_n_used 
)
static

◆ ar_rehash()

static void ar_rehash ( mrb_state mrb,
struct RHash h 
)
static

Definition at line 541 of file hash.c.

References ar_ea(), ar_ea_capa(), ar_size(), RHash::ea, ea_each, ea_get_by_key(), h, hash_entry::key, and size.

Referenced by h_rehash().

◆ ar_set()

◆ ar_set_ea()

static void ar_set_ea ( struct RHash h,
hash_entry v 
)
inlinestatic

Definition at line 159 of file hash.c.

Referenced by ar_adjust_ea(), and ar_init().

◆ ar_set_ea_capa()

static void ar_set_ea_capa ( struct RHash h,
uint32_t  v 
)
inlinestatic

Definition at line 147 of file hash.c.

Referenced by ar_adjust_ea(), and ar_init().

◆ ar_set_ea_n_used()

static void ar_set_ea_n_used ( struct RHash h,
uint32_t  v 
)
inlinestatic

Definition at line 148 of file hash.c.

Referenced by ar_compress(), ar_init(), and ar_set().

◆ ar_set_size()

static void ar_set_size ( struct RHash h,
uint32_t  v 
)
inlinestatic

Definition at line 158 of file hash.c.

Referenced by ar_init(), ar_set(), and ar_shift().

◆ ar_shift()

static void ar_shift ( mrb_state mrb,
struct RHash h,
mrb_value keyp,
mrb_value valp 
)
static

Definition at line 528 of file hash.c.

References ar_ea(), ar_set_size(), ar_size(), ea_each, entry, entry_delete(), h, and size.

Referenced by h_shift().

◆ ar_size()

static uint32_t ar_size ( const struct RHash h)
inlinestatic

Definition at line 158 of file hash.c.

Referenced by ar_compress(), ar_delete(), ar_get(), ar_rehash(), ar_set(), and ar_shift().

◆ ea_adjust()

static hash_entry* ea_adjust ( mrb_state mrb,
hash_entry ea,
uint32_t capap,
uint32_t  max_capa 
)
static

Definition at line 400 of file hash.c.

References RHash::ea, ea_next_capa_for(), and ea_resize().

Referenced by ar_adjust_ea(), ar_set(), ht_adjust_ea(), and ht_to_ar().

◆ ea_compress()

static void ea_compress ( hash_entry ea,
uint32_t  n_used 
)
static

Definition at line 384 of file hash.c.

References RHash::ea, ea_each_used, and entry_deleted_p().

Referenced by ar_compress(), ht_set(), and ht_to_ar().

◆ ea_dup()

static hash_entry* ea_dup ( mrb_state mrb,
const hash_entry ea,
uint32_t  capa 
)
static

Definition at line 407 of file hash.c.

References RHash::ea, memcpy, and mrb_malloc().

Referenced by h_replace().

◆ ea_get()

static hash_entry* ea_get ( hash_entry ea,
uint32_t  index 
)
static

Definition at line 425 of file hash.c.

References RHash::ea, and index.

Referenced by ib_it_entry().

◆ ea_get_by_key()

static hash_entry* ea_get_by_key ( mrb_state mrb,
hash_entry ea,
uint32_t  size,
mrb_value  key,
struct RHash h 
)
static

Definition at line 415 of file hash.c.

References RHash::ea, ea_each, entry, h, key, NULL, obj_eql(), and size.

Referenced by ar_delete(), ar_rehash(), and ar_set().

◆ ea_next_capa_for()

static uint32_t ea_next_capa_for ( uint32_t  size,
uint32_t  max_capa 
)
static

Definition at line 359 of file hash.c.

References AR_DEFAULT_CAPA, EA_INCREASE_RATIO, EA_MAX_INCREASE, size, size_t, and U32.

Referenced by ea_adjust(), and ht_set().

◆ ea_resize()

static hash_entry* ea_resize ( mrb_state mrb,
hash_entry ea,
uint32_t  capa 
)
static

Definition at line 378 of file hash.c.

References RHash::ea, and mrb_realloc().

Referenced by ea_adjust(), and mrb_hash_new_capa().

◆ ea_set()

static void ea_set ( hash_entry ea,
uint32_t  index,
mrb_value  key,
mrb_value  val 
)
static

Definition at line 431 of file hash.c.

References RHash::ea, index, key, hash_entry::key, val, and hash_entry::val.

Referenced by ar_set(), and ht_set_without_ib_adjustment().

◆ entry_delete()

static void entry_delete ( hash_entry entry)
static

Definition at line 353 of file hash.c.

References entry, and mrb_undef_value().

Referenced by ar_delete(), ar_shift(), and ht_delete().

◆ entry_deleted_p()

static mrb_bool entry_deleted_p ( const hash_entry entry)
static

Definition at line 347 of file hash.c.

References entry, and mrb_undef_p.

Referenced by ea_compress().

◆ h_alloc()

static struct RHash* h_alloc ( mrb_state mrb)
static

Definition at line 934 of file hash.c.

References mrb_state::hash_class, mrb_obj_alloc(), and MRB_TT_HASH.

Referenced by mrb_hash_dup(), mrb_hash_new(), and mrb_hash_new_capa().

◆ h_clear()

static void h_clear ( mrb_state mrb,
struct RHash h 
)
static

Definition at line 952 of file hash.c.

References h, h_free_table(), and h_init().

Referenced by h_rehash(), h_replace(), and mrb_hash_clear().

◆ h_delete()

static mrb_bool h_delete ( mrb_state mrb,
struct RHash h,
mrb_value  key,
mrb_value valp 
)
static

Definition at line 971 of file hash.c.

References ar_delete(), h, h_ar_p, ht_delete(), and key.

Referenced by mrb_hash_delete_key().

◆ h_free_table()

static void h_free_table ( mrb_state mrb,
struct RHash h 
)
static

Definition at line 946 of file hash.c.

References ar_free(), h, h_ar_p, and ht_free().

Referenced by h_clear(), h_replace(), and mrb_gc_free_hash().

◆ h_get()

static mrb_bool h_get ( mrb_state mrb,
struct RHash h,
mrb_value  key,
mrb_value valp 
)
static

Definition at line 959 of file hash.c.

References ar_get(), h, h_ar_p, ht_get(), and key.

Referenced by mrb_hash_fetch(), mrb_hash_get(), and mrb_hash_key_p().

◆ h_ht()

static hash_table* h_ht ( const struct RHash h)
inlinestatic

Definition at line 167 of file hash.c.

Referenced by ht_dup(), ht_free(), ht_rehash(), ht_set(), and ht_to_ar().

◆ h_ht_off()

static void h_ht_off ( struct RHash h)
inlinestatic

Definition at line 168 of file hash.c.

◆ h_ht_on()

static void h_ht_on ( struct RHash h)
inlinestatic

Definition at line 168 of file hash.c.

Referenced by h_replace(), and ht_init().

◆ h_ht_p()

static mrb_bool h_ht_p ( const struct RHash h)
inlinestatic

Definition at line 168 of file hash.c.

◆ h_init()

static void h_init ( struct RHash h)
static

Definition at line 940 of file hash.c.

References ar_init(), h, and NULL.

Referenced by h_clear().

◆ h_key_for()

static mrb_value h_key_for ( mrb_state mrb,
mrb_value  key 
)
static

Definition at line 924 of file hash.c.

References key, MRB_FROZEN_P, MRB_SET_FROZEN_FLAG, mrb_str_dup(), mrb_str_ptr, and mrb_string_p.

Referenced by mrb_hash_set().

◆ h_rehash()

static void h_rehash ( mrb_state mrb,
struct RHash h 
)
static

Definition at line 984 of file hash.c.

References ar_rehash(), h, h_ar_p, h_clear(), h_size(), and ht_rehash().

Referenced by mrb_hash_rehash().

◆ h_replace()

◆ h_set()

static void h_set ( mrb_state mrb,
struct RHash h,
mrb_value  key,
mrb_value  val 
)
static

Definition at line 965 of file hash.c.

References ar_set(), h, h_ar_p, ht_set(), and key.

Referenced by mrb_hash_merge(), and mrb_hash_set().

◆ h_set_ht()

static void h_set_ht ( struct RHash h,
hash_table v 
)
inlinestatic

Definition at line 167 of file hash.c.

Referenced by h_replace(), and ht_init().

◆ h_shift()

static void h_shift ( mrb_state mrb,
struct RHash h,
mrb_value keyp,
mrb_value valp 
)
static

Definition at line 978 of file hash.c.

References ar_shift(), h, h_ar_p, and ht_shift().

Referenced by mrb_hash_shift().

◆ h_size()

◆ hash_default()

static mrb_value hash_default ( mrb_state mrb,
mrb_value  hash,
mrb_value  key 
)
static

◆ hash_modify()

◆ hash_replace()

static void hash_replace ( mrb_state mrb,
mrb_value  self,
mrb_value  orig 
)
static

◆ ht_adjust_ea()

static void ht_adjust_ea ( mrb_state mrb,
struct RHash h,
uint32_t  size,
uint32_t  max_ea_capa 
)
static

Definition at line 774 of file hash.c.

References RHash::ea, ea_adjust(), h, ht_ea(), ht_set_ea(), ht_set_ea_capa(), and size.

Referenced by ht_set(), and ht_set_without_ib_adjustment().

◆ ht_dec_size()

static void ht_dec_size ( struct RHash h)
inlinestatic

Definition at line 165 of file hash.c.

Referenced by ht_delete().

◆ ht_delete()

static mrb_bool ht_delete ( mrb_state mrb,
struct RHash h,
mrb_value  key,
mrb_value valp 
)
static

Definition at line 861 of file hash.c.

References entry, entry_delete(), FALSE, h, ht_dec_size(), ib_find_by_key, ib_it_delete(), ib_it_entry(), key, and TRUE.

Referenced by h_delete().

◆ ht_dup()

static hash_table* ht_dup ( mrb_state mrb,
const struct RHash h 
)
static

Definition at line 765 of file hash.c.

References h, h_ht(), ib_bit(), ib_byte_size_for(), memcpy, and mrb_malloc().

Referenced by h_replace().

◆ ht_ea()

static hash_entry* ht_ea ( const struct RHash h)
inlinestatic

◆ ht_ea_capa()

static uint32_t ht_ea_capa ( const struct RHash h)
inlinestatic

Definition at line 149 of file hash.c.

Referenced by h_replace(), ht_rehash(), ht_set(), ht_set_without_ib_adjustment(), and mrb_hash_memsize().

◆ ht_ea_n_used()

static uint32_t ht_ea_n_used ( const struct RHash h)
inlinestatic

Definition at line 150 of file hash.c.

Referenced by h_replace(), ht_rehash(), ht_set(), ht_set_without_ib_adjustment(), ht_to_ar(), and ib_init().

◆ ht_free()

static void ht_free ( mrb_state mrb,
struct RHash h 
)
static

Definition at line 758 of file hash.c.

References h, h_ht(), ht_ea(), and mrb_free().

Referenced by h_free_table().

◆ ht_get()

static mrb_bool ht_get ( mrb_state mrb,
struct RHash h,
mrb_value  key,
mrb_value valp 
)
static

Definition at line 794 of file hash.c.

References FALSE, h, ib_find_by_key, ib_it_entry(), key, TRUE, and hash_entry::val.

Referenced by h_get().

◆ ht_ib()

static uint32_t* ht_ib ( const struct RHash h)
inlinestatic

Definition at line 163 of file hash.c.

Referenced by ib_init(), ib_it_next(), and ib_it_set().

◆ ht_inc_size()

static void ht_inc_size ( struct RHash h)
inlinestatic

Definition at line 164 of file hash.c.

Referenced by ht_set_without_ib_adjustment().

◆ ht_init()

static void ht_init ( mrb_state mrb,
struct RHash h,
uint32_t  size,
hash_entry ea,
uint32_t  ea_capa,
hash_table ht,
uint32_t  ib_bit 
)
static

◆ ht_rehash()

static void ht_rehash ( mrb_state mrb,
struct RHash h 
)
static

◆ ht_set()

◆ ht_set_as_ar()

static void ht_set_as_ar ( mrb_state mrb,
struct RHash h,
mrb_value  key,
mrb_value  val 
)
static

Definition at line 804 of file hash.c.

References ar_set(), h, ht_to_ar(), and key.

Referenced by ht_set().

◆ ht_set_ea()

static void ht_set_ea ( struct RHash h,
hash_entry v 
)
inlinestatic

Definition at line 162 of file hash.c.

Referenced by h_replace(), ht_adjust_ea(), and ht_init().

◆ ht_set_ea_capa()

static void ht_set_ea_capa ( struct RHash h,
uint32_t  v 
)
inlinestatic

Definition at line 149 of file hash.c.

Referenced by h_replace(), ht_adjust_ea(), and ht_init().

◆ ht_set_ea_n_used()

static void ht_set_ea_n_used ( struct RHash h,
uint32_t  v 
)
inlinestatic

Definition at line 150 of file hash.c.

Referenced by h_replace(), ht_init(), ht_rehash(), and ht_set_without_ib_adjustment().

◆ ht_set_size()

static void ht_set_size ( struct RHash h,
uint32_t  v 
)
inlinestatic

Definition at line 161 of file hash.c.

Referenced by h_replace(), ht_init(), and ht_rehash().

◆ ht_set_without_ib_adjustment()

◆ ht_shift()

static void ht_shift ( mrb_state mrb,
struct RHash h,
mrb_value keyp,
mrb_value valp 
)
static

Definition at line 875 of file hash.c.

References RHash::ea, ea_each, entry, h, ht_ea(), ht_size(), and ib_cycle_by_key.

Referenced by h_shift().

◆ ht_size()

static uint32_t ht_size ( const struct RHash h)
inlinestatic

Definition at line 161 of file hash.c.

Referenced by ht_rehash(), ht_set(), ht_set_without_ib_adjustment(), ht_shift(), and ht_to_ar().

◆ ht_to_ar()

static void ht_to_ar ( mrb_state mrb,
struct RHash h 
)
static

Definition at line 783 of file hash.c.

References ar_init(), AR_MAX_SIZE, RHash::ea, ea_adjust(), ea_compress(), h, h_ht(), ht_ea(), ht_ea_n_used(), ht_size(), mrb_free(), and size.

Referenced by ht_set_as_ar().

◆ ib_bit()

static uint32_t ib_bit ( const struct RHash h)
inlinestatic

◆ ib_bit_for()

static uint32_t ib_bit_for ( uint32_t  size)
static

Definition at line 711 of file hash.c.

References ib_capa_to_bit(), IB_MAX_CAPA, ib_upper_bound_for(), next_power2(), and size.

Referenced by ht_rehash(), and mrb_hash_new_capa().

◆ ib_bit_to_capa()

static uint32_t ib_bit_to_capa ( uint32_t  bit)
static

Definition at line 699 of file hash.c.

References U32.

Referenced by ht_set(), ht_set_without_ib_adjustment(), ib_byte_size_for(), and ib_it_init().

◆ ib_byte_size_for()

static uint32_t ib_byte_size_for ( uint32_t  ib_bit)
static

Definition at line 719 of file hash.c.

References ib_bit(), ib_bit_to_capa(), IB_INIT_BIT, IB_TYPE_BIT, and U32.

Referenced by ht_dup(), ht_init(), and mrb_hash_memsize().

◆ ib_capa_to_bit()

static uint32_t ib_capa_to_bit ( uint32_t  capa)
static

Definition at line 684 of file hash.c.

References U32.

Referenced by ib_bit_for().

◆ ib_init()

static void ib_init ( mrb_state mrb,
struct RHash h,
uint32_t  ib_bit,
size_t  ib_byte_size 
)
static

Definition at line 728 of file hash.c.

References RHash::ea, ea_each_used, entry, h, ht_ea(), ht_ea_n_used(), ht_ib(), ib_bit(), ib_cycle_by_key, ib_set_bit(), and memset().

Referenced by ht_init().

◆ ib_it_active_p()

static mrb_bool ib_it_active_p ( const index_buckets_iter it)
static

Definition at line 596 of file hash.c.

References index_buckets_iter::ea_index, and ib_it_deleted_value().

Referenced by ht_set_without_ib_adjustment().

◆ ib_it_delete()

static void ib_it_delete ( index_buckets_iter it)
static

Definition at line 672 of file hash.c.

References ib_it_deleted_value(), and ib_it_set().

Referenced by ht_delete().

◆ ib_it_deleted_p()

static mrb_bool ib_it_deleted_p ( const index_buckets_iter it)
static

Definition at line 590 of file hash.c.

References index_buckets_iter::ea_index, and ib_it_deleted_value().

◆ ib_it_deleted_value()

static uint32_t ib_it_deleted_value ( const index_buckets_iter it)
static

Definition at line 578 of file hash.c.

References index_buckets_iter::mask.

Referenced by ib_it_active_p(), ib_it_delete(), and ib_it_deleted_p().

◆ ib_it_empty_p()

static mrb_bool ib_it_empty_p ( const index_buckets_iter it)
static

Definition at line 584 of file hash.c.

References index_buckets_iter::ea_index, and ib_it_empty_value().

◆ ib_it_empty_value()

static uint32_t ib_it_empty_value ( const index_buckets_iter it)
static

Definition at line 572 of file hash.c.

References index_buckets_iter::mask.

Referenced by ib_it_empty_p().

◆ ib_it_entry()

static hash_entry* ib_it_entry ( index_buckets_iter it)
static

◆ ib_it_get()

static uint32_t ib_it_get ( const index_buckets_iter it)
static

Definition at line 651 of file hash.c.

References index_buckets_iter::ea_index.

◆ ib_it_init()

◆ ib_it_next()

◆ ib_it_pos_for()

static uint32_t ib_it_pos_for ( index_buckets_iter it,
uint32_t  v 
)
static

Definition at line 566 of file hash.c.

References index_buckets_iter::mask, and v.

Referenced by ib_it_init(), and ib_it_next().

◆ ib_it_set()

◆ ib_set_bit()

static void ib_set_bit ( struct RHash h,
uint32_t  v 
)
inlinestatic

Definition at line 157 of file hash.c.

Referenced by h_replace(), and ib_init().

◆ ib_upper_bound_for()

static uint32_t ib_upper_bound_for ( uint32_t  capa)
static

Definition at line 705 of file hash.c.

Referenced by ht_set(), and ib_bit_for().

◆ mrb_gc_free_hash()

void mrb_gc_free_hash ( mrb_state mrb,
struct RHash h 
)

Definition at line 1045 of file hash.c.

References h, and h_free_table().

Referenced by obj_free().

◆ mrb_gc_mark_hash()

void mrb_gc_mark_hash ( mrb_state mrb,
struct RHash h 
)

Definition at line 1030 of file hash.c.

References entry, h, h_each, and mrb_gc_mark_value.

Referenced by gc_mark_children().

◆ mrb_gc_mark_hash_size()

size_t mrb_gc_mark_hash_size ( mrb_state mrb,
struct RHash h 
)

Definition at line 1039 of file hash.c.

References h, and h_size().

Referenced by gc_gray_counts().

◆ mrb_hash_aget()

static mrb_value mrb_hash_aget ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1288 of file hash.c.

References key, mrb_get_arg1(), and mrb_hash_get().

Referenced by mrb_init_hash().

◆ mrb_hash_aset()

static mrb_value mrb_hash_aset ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1523 of file hash.c.

References key, mrb_get_args(), mrb_hash_set(), and val.

Referenced by mrb_init_hash().

◆ mrb_hash_check_kdict()

void mrb_hash_check_kdict ( mrb_state mrb,
mrb_value  self 
)

Definition at line 1156 of file hash.c.

References E_ARGUMENT_ERROR, entry, h_each, mrb_hash_ptr, mrb_raise(), and mrb_symbol_p.

Referenced by mrb_get_args(), and mrb_vm_exec().

◆ mrb_hash_clear()

mrb_value mrb_hash_clear ( mrb_state mrb,
mrb_value  hash 
)

Definition at line 1496 of file hash.c.

References h_clear(), hash(), hash_modify(), and mrb_hash_ptr.

Referenced by mrb_init_hash(), and os_count_objects().

◆ mrb_hash_default()

static mrb_value mrb_hash_default ( mrb_state mrb,
mrb_value  hash 
)
static

◆ mrb_hash_default_proc()

static mrb_value mrb_hash_default_proc ( mrb_state mrb,
mrb_value  hash 
)
static

Definition at line 1390 of file hash.c.

References hash(), mrb_nil_value(), MRB_RHASH_PROCDEFAULT_P, and RHASH_PROCDEFAULT.

Referenced by mrb_init_hash().

◆ mrb_hash_delete()

static mrb_value mrb_hash_delete ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1445 of file hash.c.

References key, mrb_get_arg1(), and mrb_hash_delete_key().

Referenced by mrb_init_hash().

◆ mrb_hash_delete_key()

mrb_value mrb_hash_delete_key ( mrb_state mrb,
mrb_value  hash,
mrb_value  key 
)

Definition at line 1431 of file hash.c.

References h_delete(), hash(), hash_modify(), key, mrb_hash_ptr, and mrb_nil_value().

Referenced by hash_except(), mrb_get_args(), mrb_hash_delete(), and mrb_vm_exec().

◆ mrb_hash_dup()

mrb_value mrb_hash_dup ( mrb_state mrb,
mrb_value  self 
)

Definition at line 1165 of file hash.c.

References copy(), h_alloc(), hash_replace(), mrb_hash_ptr, and mrb_obj_value().

Referenced by hash_except(), mrb_get_args(), and mrb_vm_exec().

◆ mrb_hash_empty_m()

static mrb_value mrb_hash_empty_m ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1576 of file hash.c.

References mrb_bool_value(), and mrb_hash_empty_p().

Referenced by mrb_init_hash().

◆ mrb_hash_empty_p()

mrb_bool mrb_hash_empty_p ( mrb_state mrb,
mrb_value  self 
)

Definition at line 1560 of file hash.c.

References h_size(), and mrb_hash_ptr.

Referenced by mrb_get_args(), mrb_hash_empty_m(), mrb_vm_exec(), and os_count_objects().

◆ mrb_hash_fetch()

mrb_value mrb_hash_fetch ( mrb_state mrb,
mrb_value  hash,
mrb_value  key,
mrb_value  def 
)

Definition at line 1193 of file hash.c.

References def, h_get(), hash(), key, mrb_hash_ptr, and val.

Referenced by hash_slice(), and mrb_str_format().

◆ mrb_hash_foreach()

void mrb_hash_foreach ( mrb_state mrb,
struct RHash h,
mrb_hash_foreach_func func,
void data 
)

Definition at line 1063 of file hash.c.

References data, entry, func, h, and h_each.

◆ mrb_hash_get()

mrb_value mrb_hash_get ( mrb_state mrb,
mrb_value  hash,
mrb_value  key 
)

◆ mrb_hash_has_key()

static mrb_value mrb_hash_has_key ( mrb_state mrb,
mrb_value  hash 
)
static

Definition at line 1656 of file hash.c.

References hash(), key, mrb_bool_value(), mrb_get_arg1(), and mrb_hash_key_p().

Referenced by mrb_init_hash().

◆ mrb_hash_has_value()

static mrb_value mrb_hash_has_value ( mrb_state mrb,
mrb_value  hash 
)
static

◆ mrb_hash_init()

◆ mrb_hash_init_copy()

static mrb_value mrb_hash_init_copy ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1146 of file hash.c.

References hash_modify(), hash_replace(), mrb_get_args(), and mrb_hash_ptr.

Referenced by mrb_init_hash().

◆ mrb_hash_key_p()

mrb_bool mrb_hash_key_p ( mrb_state mrb,
mrb_value  hash,
mrb_value  key 
)

Definition at line 1649 of file hash.c.

References h_get(), hash(), key, mrb_hash_ptr, and val.

Referenced by mrb_get_args(), mrb_hash_has_key(), and mrb_vm_exec().

◆ mrb_hash_keys()

mrb_value mrb_hash_keys ( mrb_state mrb,
mrb_value  hash 
)

◆ mrb_hash_memsize()

size_t mrb_hash_memsize ( mrb_value  self)

◆ mrb_hash_merge()

void mrb_hash_merge ( mrb_state mrb,
mrb_value  hash1,
mrb_value  hash2 
)

◆ mrb_hash_new()

◆ mrb_hash_new_capa()

◆ mrb_hash_rehash()

static mrb_value mrb_hash_rehash ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1733 of file hash.c.

References h_rehash(), and mrb_hash_ptr.

Referenced by mrb_init_hash().

◆ mrb_hash_set()

◆ mrb_hash_set_default()

static mrb_value mrb_hash_set_default ( mrb_state mrb,
mrb_value  hash 
)
static

Definition at line 1358 of file hash.c.

References hash(), hash_modify(), mrb_get_arg1(), MRB_HASH_DEFAULT, mrb_iv_set(), mrb_nil_p, MRB_SYM, and RHASH.

Referenced by mrb_init_hash().

◆ mrb_hash_set_default_proc()

static mrb_value mrb_hash_set_default_proc ( mrb_state mrb,
mrb_value  hash 
)
static

◆ mrb_hash_shift()

static mrb_value mrb_hash_shift ( mrb_state mrb,
mrb_value  hash 
)
static

◆ mrb_hash_size()

mrb_int mrb_hash_size ( mrb_state mrb,
mrb_value  hash 
)

Definition at line 1533 of file hash.c.

References h_size(), hash(), and mrb_hash_ptr.

Referenced by mrb_hash_size_m().

◆ mrb_hash_size_m()

static mrb_value mrb_hash_size_m ( mrb_state mrb,
mrb_value  self 
)
static

Definition at line 1553 of file hash.c.

References mrb_hash_size(), mrb_int_value(), and size.

Referenced by mrb_init_hash().

◆ mrb_hash_values()

mrb_value mrb_hash_values ( mrb_state mrb,
mrb_value  hash 
)

Definition at line 1619 of file hash.c.

References entry, h, h_each, h_size(), hash(), mrb_ary_new_capa(), mrb_ary_push(), and mrb_hash_ptr.

Referenced by mrb_init_hash().

◆ mrb_init_hash()

◆ next_power2()

static uint32_t next_power2 ( uint32_t  v)
static

Definition at line 270 of file hash.c.

References CHAR_BIT, mrb_assert, U32, and v.

Referenced by ib_bit_for().

◆ obj_eql()

◆ obj_hash_code()

static uint32_t obj_hash_code ( mrb_state mrb,
mrb_value  key,
struct RHash h 
)
static