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

Method entry_with_depth

cranelift/codegen/src/scoped_hash_map.rs:114–141  ·  view source on GitHub ↗

Get the entry, setting the scope depth at which to insert.

(&'a mut self, ctx: &C, key: K, depth: usize)

Source from the content-addressed store, hash-verified

112
113 /// Get the entry, setting the scope depth at which to insert.
114 pub fn entry_with_depth<'a, C>(&'a mut self, ctx: &C, key: K, depth: usize) -> Entry<'a, K, V>
115 where
116 C: CtxEq<K, K> + CtxHash<K>,
117 {
118 debug_assert!(depth <= self.generation_by_depth.len());
119 let generation = self.generation_by_depth[depth];
120 let depth = depth as u32;
121 match self.map.entry(key, ctx) {
122 crate::ctxhash::Entry::Occupied(entry) => {
123 let entry_generation = entry.get().generation;
124 let entry_depth = entry.get().level as usize;
125 if self.generation_by_depth.get(entry_depth).cloned() == Some(entry_generation) {
126 Entry::Occupied(OccupiedEntry { entry })
127 } else {
128 Entry::Vacant(VacantEntry {
129 entry: InsertLoc::Occupied(entry),
130 depth,
131 generation,
132 })
133 }
134 }
135 crate::ctxhash::Entry::Vacant(entry) => Entry::Vacant(VacantEntry {
136 entry: InsertLoc::Vacant(entry),
137 depth,
138 generation,
139 }),
140 }
141 }
142
143 /// Get a value from a key, if present.
144 pub fn get<'a, C>(&'a self, ctx: &C, key: &K) -> Option<&'a V>

Callers 2

entryMethod · 0.80

Calls 2

entryMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected