MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / insert

Method insert

cranelift/codegen/src/ctxhash.rs:87–103  ·  view source on GitHub ↗

Insert a new key-value pair, returning the old value associated with this key (if any).

(&mut self, k: K, v: V, ctx: &Ctx)

Source from the content-addressed store, hash-verified

85 /// Insert a new key-value pair, returning the old value associated
86 /// with this key (if any).
87 pub fn insert<Ctx>(&mut self, k: K, v: V, ctx: &Ctx) -> Option<V>
88 where
89 Ctx: CtxEq<K, K> + CtxHash<K>,
90 {
91 let hash = compute_hash(ctx, &k);
92 match self.raw.find_mut(hash as u64, |bucket| {
93 hash == bucket.hash && ctx.ctx_eq(&bucket.k, &k)
94 }) {
95 Some(bucket) => Some(core::mem::replace(&mut bucket.v, v)),
96 None => {
97 let data = BucketData { hash, k, v };
98 self.raw
99 .insert_unique(hash as u64, data, |bucket| bucket.hash as u64);
100 None
101 }
102 }
103 }
104
105 /// Look up a key, returning a borrow of the value if present.
106 pub fn get<'a, Q, Ctx>(&'a self, k: &Q, ctx: &Ctx) -> Option<&'a V>

Callers 15

nextMethod · 0.45
setMethod · 0.45
do_remove_constant_phisFunction · 0.45
harvest_candidate_lhsFunction · 0.45
post_order_dfsFunction · 0.45
map_mem_flagsMethod · 0.45
create_global_valuesFunction · 0.45
create_constantsFunction · 0.45
add_edgeMethod · 0.45
rematMethod · 0.45
subsumeMethod · 0.45

Calls 4

compute_hashFunction · 0.85
find_mutMethod · 0.80
replaceFunction · 0.50
ctx_eqMethod · 0.45

Tested by

no test coverage detected