Lines Matching defs:key
1124 upb_strview key = upb_strtable_iter_key(&i);
1127 _upb_map_fromkey(key, &ent.k, map->key_size);
1437 /* A type to represent the lookup key of either a strtable or an inttable. */
1453 static lookupkey_t intkey(uintptr_t key) {
1455 k.num = key;
1459 typedef uint32_t hashfunc_t(upb_tabkey key);
1507 static const upb_tabent *findentry(const upb_table *t, lookupkey_t key,
1515 if (eql(e->key, key)) return e;
1520 static upb_tabent *findentry_mutable(upb_table *t, lookupkey_t key,
1522 return (upb_tabent*)findentry(t, key, hash, eql);
1525 static bool lookup(const upb_table *t, lookupkey_t key, upb_value *v,
1527 const upb_tabent *e = findentry(t, key, hash, eql);
1538 /* The given key must not already exist in the table. */
1539 static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
1545 UPB_ASSERT(findentry(t, key, hash, eql) == NULL);
1558 upb_tabent *chain = getentry_mutable(t, hashfunc(mainpos_e->key));
1579 our_e->key = tabkey;
1581 UPB_ASSERT(findentry(t, key, hash, eql) == our_e);
1584 static bool rm(upb_table *t, lookupkey_t key, upb_value *val,
1588 if (eql(chain->key, key)) {
1592 if (removed) *removed = chain->key;
1596 move->key = 0; /* Make the slot empty. */
1598 chain->key = 0; /* Make the slot empty. */
1604 while (chain->next && !eql(chain->next->key, key)) {
1612 if (removed) *removed = rm->key;
1613 rm->key = 0; /* Make the slot empty. */
1651 static uint32_t strhash(upb_tabkey key) {
1653 char *str = upb_tabstr(key, &len);
1677 upb_free(a, (void*)t->t.entries[i].key);
1689 upb_strview key = upb_strtable_iter_key(&i);
1691 &new_table, key.data, key.size,
1701 lookupkey_t key;
1712 key = strkey2(k, len);
1713 tabkey = strcopy(key, a);
1716 hash = upb_murmur_hash2(key.str.str, key.str.len, 0);
1717 insert(&t->t, key, tabkey, v, hash, &strhash, &streql);
1721 bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len,
1723 uint32_t hash = upb_murmur_hash2(key, len, 0);
1724 return lookup(&t->t, strkey2(key, len), v, hash, &streql);
1727 bool upb_strtable_remove3(upb_strtable *t, const char *key, size_t len,
1729 uint32_t hash = upb_murmur_hash2(key, len, 0);
1731 if (rm(&t->t, strkey2(key, len), val, &tabkey, hash, &streql)) {
1760 upb_strview key;
1763 key.data = upb_tabstr(str_tabent(i)->key, &len);
1764 key.size = len;
1765 return key;
1791 static uint32_t inthash(upb_tabkey key) { return upb_inthash(key); }
1801 static upb_tabval *inttable_val(upb_inttable *t, uintptr_t key) {
1802 if (key < t->array_size) {
1803 return upb_arrhas(t->array[key]) ? &(mutable_array(t)[key]) : NULL;
1806 findentry_mutable(&t->t, intkey(key), upb_inthash(key), &inteql);
1812 uintptr_t key) {
1813 return inttable_val((upb_inttable*)t, key);
1841 /* Always make the array part at least 1 long, so that we know key 0
1866 bool upb_inttable_insert2(upb_inttable *t, uintptr_t key, upb_value val,
1872 if (key < t->array_size) {
1873 UPB_ASSERT(!upb_arrhas(t->array[key]));
1875 mutable_array(t)[key].val = val.val;
1892 hash = upb_inthash(e->key);
1893 insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql);
1901 insert(&t->t, intkey(key), key, val, upb_inthash(key), &inthash, &inteql);
1907 bool upb_inttable_lookup(const upb_inttable *t, uintptr_t key, upb_value *v) {
1908 const upb_tabval *table_v = inttable_val_const(t, key);
1914 bool upb_inttable_replace(upb_inttable *t, uintptr_t key, upb_value val) {
1915 upb_tabval *table_v = inttable_val(t, key);
1921 bool upb_inttable_remove(upb_inttable *t, uintptr_t key, upb_value *val) {
1923 if (key < t->array_size) {
1924 if (upb_arrhas(t->array[key])) {
1928 _upb_value_setval(val, t->array[key].val);
1930 mutable_array(t)[key] = empty;
1936 success = rm(&t->t, intkey(key), val, NULL, upb_inthash(key), &inteql);
1942 bool upb_inttable_insertptr2(upb_inttable *t, const void *key, upb_value val,
1944 return upb_inttable_insert2(t, (uintptr_t)key, val, a);
1947 bool upb_inttable_lookupptr(const upb_inttable *t, const void *key,
1949 return upb_inttable_lookup(t, (uintptr_t)key, v);
1952 bool upb_inttable_removeptr(upb_inttable *t, const void *key, upb_value *val) {
1953 return upb_inttable_remove(t, (uintptr_t)key, val);
1960 /* The max key in each bucket. */
1970 uintptr_t key = upb_inttable_iter_key(&i);
1971 int bucket = log2ceil(key);
1972 max[bucket] = UPB_MAX(max[bucket], key);
2060 return i->array_part ? i->index : int_tabent(i)->key;
2094 uint32_t upb_murmur_hash2(const void *key, size_t len, uint32_t seed) {
2104 const uint8_t * data = (const uint8_t *)key;
2146 uint32_t upb_murmur_hash2(const void * key, size_t len, uint32_t seed) {
2149 const uint8_t * data = (const uint8_t *)key;
4379 const upb_fielddef *key = upb_msgdef_itof(m, 1);
4387 fields[0].descriptortype = upb_fielddef_descriptortype(key);
5383 upb_strview key = upb_strtable_iter_key(&iter);
5385 CHK_OOM(upb_strtable_insert3(&s->syms, key.data, key.size, value, alloc));
5731 const upb_fielddef *key = upb_msgdef_itof(entry, UPB_MAPENTRY_KEY);
5733 ret.map = upb_map_new(a, upb_fielddef_type(key), upb_fielddef_type(value));
5924 bool upb_map_get(const upb_map *map, upb_msgval key, upb_msgval *val) {
5925 return _upb_map_get(map, &key, map->key_size, val, map->val_size);
5928 bool upb_map_set(upb_map *map, upb_msgval key, upb_msgval val,
5930 return _upb_map_set(map, &key, map->key_size, &val, map->val_size, arena);
5933 bool upb_map_delete(upb_map *map, upb_msgval key) {
5934 return _upb_map_delete(map, &key, map->key_size);
5949 /* Returns the key and value for this entry of the map. */
6791 jsondec_err(d, "Invalid boolean map key");
6832 upb_msgval key, val;
6833 key = jsondec_value(d, key_f);
6836 upb_map_set(map, key, val, d->arena);
7116 upb_msgval key, value;
7118 key.str_val = jsondec_string(d);
7120 upb_map_set(fields, key, value, d->arena);
7817 upb_msgval key = upb_mapiter_key(fields, iter);
7821 jsonenc_string(e, key.str_val);