Go to the documentation of this file.
39 #include "upb/port_def.inc"
41 #define UPB_MAXARRSIZE 16
44 #define ARRAY_SIZE(x) \
45 ((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x])))))
65 while (
v >>= 1)
ret++;
117 return t->entries + (
hash & t->mask);
128 t->size_lg2 = size_lg2;
134 if (!t->entries)
return false;
145 for (e = e + 1; e <
end; e++) {
163 if (t->size_lg2 == 0)
return NULL;
167 if (eql(e->key,
key))
return e;
168 if ((e = e->next) == NULL)
return NULL;
211 if (chain == mainpos_e) {
216 mainpos_e->
next = new_e;
223 while (chain->
next != mainpos_e) {
241 if (eql(chain->
key,
key)) {
245 if (removed) *removed = chain->
key;
265 if (removed) *removed =
rm->key;
294 if (
str == NULL)
return 0;
315 #if defined(_MSC_VER) && defined(_M_X64)
322 #ifdef __SIZEOF_INT128__
327 #elif defined(_MSC_VER) && defined(_M_X64)
328 return _umul128(v0, v1, out_high);
338 low += (mid1 << 32) + (mid2 << 32);
340 high += (mid1 >> 32) + (mid2 >> 32);
362 uint64_t duplicated_state = current_state;
376 current_state = (cs0 ^ cs1);
380 duplicated_state = (ds0 ^ ds1);
386 current_state = current_state ^ duplicated_state;
395 current_state =
WyhashMix(
a ^ salt[1],
b ^ current_state);
411 }
else if (
len > 3) {
416 }
else if (
len > 0) {
432 0x243F6A8885A308D3
ULL, 0x13198A2E03707344
ULL, 0xA4093822299F31D0
ULL,
433 0x082EFA98EC4E6C89
ULL, 0x452821E638D01377
ULL,
453 return len ==
k2.str.len && (
len == 0 || memcmp(
str,
k2.str.str,
len) == 0);
459 size_t need_entries = (expected_size + 1) * 1204 / 1024;
460 UPB_ASSERT(need_entries >= expected_size * 0.85);
462 return init(&t->t, size_lg2,
a);
475 if (!
init(&new_table.
t, size_lg2,
a))
return false;
501 if (tabkey == 0)
return false;
529 i->index =
next(&
i->t->t,
i->index);
533 if (!
i->t)
return true;
560 return i1->t ==
i2->t &&
i1->index ==
i2->index;
577 if (key < t->array_size) {
582 return e ? &e->val : NULL;
592 return t->t.count + t->array_count;
597 #if defined(UPB_DEBUG_TABLE) && !defined(NDEBUG)
615 if (!
init(&t->t, hsize_lg2,
a))
return false;
618 t->array_size =
UPB_MAX(1, asize);
620 array_bytes = t->array_size *
sizeof(
upb_value);
641 if (key < t->array_size) {
651 if (!
init(&new_table, t->t.size_lg2 + 1,
a)) {
677 if (!table_v)
return false;
684 if (!table_v)
return false;
691 if (key < t->array_size) {
734 for (size_lg2 =
ARRAY_SIZE(counts) - 1; size_lg2 > 0; size_lg2--) {
735 if (counts[size_lg2] == 0) {
738 }
else if (arr_count >= (1 << size_lg2) *
MIN_DENSITY) {
742 arr_count -= counts[size_lg2];
749 size_t arr_size =
max[size_lg2] + 1;
751 size_t hash_size = hash_count ? (hash_count /
MAX_LOAD) + 1 : 0;
752 int hashsize_lg2 =
log2ceil(hash_size);
770 return &
i->t->t.entries[
i->index];
775 return i->t->array[
i->index];
781 i->array_part =
true;
787 if (
iter->array_part) {
788 while (++
iter->index < t->array_size) {
793 iter->array_part =
false;
803 if (i < t->array_size) {
804 while (++i < t->array_size) {
815 size_t tab_idx =
next(&t->t,
i == -1 ? -1 :
i - t->array_size);
820 *
iter = tab_idx + t->array_size;
829 if (i < t->array_size) {
833 upb_tabent* ent = &t->t.entries[
i - t->array_size];
839 if (e->next == ent) {
857 size_t tab_idx =
next(&t->t, *
iter);
879 if (e->next == ent) {
895 if (!
i->t)
return true;
918 i->array_part =
false;
924 return i1->t ==
i2->t &&
i1->index ==
i2->index &&
925 i1->array_part ==
i2->array_part;
static lookupkey_t strkey2(const char *str, size_t len)
static int log2ceil(uint64_t v)
bool upb_inttable_sizedinit(upb_inttable *t, size_t asize, int hsize_lg2, upb_Arena *a)
void upb_inttable_removeiter(upb_inttable *t, intptr_t *iter)
uint32_t hashfunc_t(upb_tabkey key)
static size_t begin(const upb_table *t)
static upb_tabval * mutable_array(upb_inttable *t)
void upb_strtable_clear(upb_strtable *t)
return memset(p, 0, total)
static uint64_t UnalignedLoad64(const void *p)
UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e)
static size_t next(const upb_table *t, size_t i)
static upb_tabent * findentry_mutable(upb_table *t, lookupkey_t key, uint32_t hash, eqlfunc_t *eql)
bool upb_inttable_init(upb_inttable *t, upb_Arena *a)
static bool init(upb_table *t, uint8_t size_lg2, upb_Arena *a)
static void check(upb_inttable *t)
static const uint8_t seed[20]
void upb_strtable_next(upb_strtable_iter *i)
bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, upb_value *v)
static uint64_t Wyhash(const void *data, size_t len, uint64_t seed, const uint64_t salt[])
struct _upb_tabent upb_tabent
char * upb_strdup2(const char *s, size_t len, upb_Arena *a)
bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val)
static const upb_tabent * int_tabent(const upb_inttable_iter *i)
static const upb_tabval * inttable_val_const(const upb_inttable *t, uintptr_t key)
UPB_INLINE char * upb_tabstr(upb_tabkey key, uint32_t *len)
void upb_inttable_begin(upb_inttable_iter *i, const upb_inttable *t)
bool upb_inttable_iter_isequal(const upb_inttable_iter *i1, const upb_inttable_iter *i2)
static upb_tabval int_arrent(const upb_inttable_iter *i)
static bool streql(upb_tabkey k1, lookupkey_t k2)
bool upb_inttable_next2(const upb_inttable *t, uintptr_t *key, upb_value *val, intptr_t *iter)
size_t upb_inttable_count(const upb_inttable *t)
static const double MAX_LOAD
bool upb_strtable_init(upb_strtable *t, size_t expected_size, upb_Arena *a)
static bool inteql(upb_tabkey k1, lookupkey_t k2)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
void upb_strtable_removeiter(upb_strtable *t, intptr_t *iter)
bool eqlfunc_t(upb_tabkey k1, lookupkey_t k2)
static upb_tabval * inttable_val(upb_inttable *t, uintptr_t key)
UPB_INLINE void * upb_Arena_Malloc(upb_Arena *a, size_t size)
static upb_tabent * getentry_mutable(upb_table *t, uint32_t hash)
unsigned __int64 uint64_t
bool upb_strtable_done(const upb_strtable_iter *i)
bool upb_inttable_done(const upb_inttable_iter *i)
void upb_strtable_iter_setdone(upb_strtable_iter *i)
const uint64_t kWyhashSalt[5]
static upb_tabent * emptyent(upb_table *t, upb_tabent *e)
_W64 unsigned int uintptr_t
static bool isfull(upb_table *t)
static const double MIN_DENSITY
static uint32_t _upb_Hash_NoSeed(const char *p, size_t n)
static uint64_t upb_umul128(uint64_t v0, uint64_t v1, uint64_t *out_high)
static uint32_t inthash(upb_tabkey key)
#define UPB_TABVALUE_EMPTY_INIT
static bool is_pow2(uint64_t v)
static uint64_t WyhashMix(uint64_t v0, uint64_t v1)
const struct _upb_tabent * next
static const upb_tabent * findentry(const upb_table *t, lookupkey_t key, uint32_t hash, eqlfunc_t *eql)
static uint32_t strhash(upb_tabkey key)
static bool rm(upb_table *t, lookupkey_t key, upb_value *val, upb_tabkey *removed, uint32_t hash, eqlfunc_t *eql)
bool upb_strtable_insert(upb_strtable *t, const char *k, size_t len, upb_value v, upb_Arena *a)
void upb_inttable_iter_setdone(upb_inttable_iter *i)
static uint32_t upb_inthash(uintptr_t key)
static lookupkey_t intkey(uintptr_t key)
void upb_inttable_compact(upb_inttable *t, upb_Arena *a)
UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val, upb_ctype_t ctype)
static const upb_tabent * str_tabent(const upb_strtable_iter *i)
UniquePtr< SSL_SESSION > ret
static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey, upb_value val, uint32_t hash, hashfunc_t *hashfunc, eqlfunc_t *eql)
static upb_tabkey strcopy(lookupkey_t k2, upb_Arena *a)
UPB_INLINE int _upb_Log2Ceiling(int x)
static bool upb_arrhas(upb_tabval key)
upb_value upb_inttable_iter_value(const upb_inttable_iter *i)
void upb_strtable_begin(upb_strtable_iter *i, const upb_strtable *t)
void upb_inttable_next(upb_inttable_iter *iter)
bool upb_strtable_iter_isequal(const upb_strtable_iter *i1, const upb_strtable_iter *i2)
bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v)
static uint32_t UnalignedLoad32(const void *p)
static bool lookup(const upb_table *t, lookupkey_t key, upb_value *v, uint32_t hash, eqlfunc_t *eql)
static upb_value _upb_value_val(uint64_t val)
bool upb_strtable_resize(upb_strtable *t, size_t size_lg2, upb_Arena *a)
uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i)
bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val)
static const upb_tabent * upb_getentry(const upb_table *t, uint32_t hash)
bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val, upb_Arena *a)
bool upb_strtable_next2(const upb_strtable *t, upb_StringView *key, upb_value *val, intptr_t *iter)
uint32_t _upb_Hash(const void *p, size_t n, uint64_t seed)
UPB_INLINE size_t upb_table_size(const upb_table *t)
if(p->owned &&p->wrapped !=NULL)
bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len, upb_value *val)
upb_value upb_strtable_iter_value(const upb_strtable_iter *i)
upb_StringView upb_strtable_iter_key(const upb_strtable_iter *i)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:29