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

Method intern

crates/environ/src/component/dfg.rs:1267–1281  ·  view source on GitHub ↗

Helper function to manage interning of results to avoid duplicate initializers being inserted into the final list. `key` - the key being referenced which is used to deduplicate. `map` - a closure to access the interning map on `Self` `gen` - a closure to generate an intermediate value with `Self` from `K`. This is only used if `key` hasn't previously been seen. This closure can recursively intern

(
        &mut self,
        key: K,
        map: impl Fn(&mut Self) -> &mut HashMap<K, V>,
        generate: impl FnOnce(&mut Self, K) -> T,
        init: impl FnOnce(V, T) -> GlobalInitializer,
    

Source from the content-addressed store, hash-verified

1265 /// initializers on-demand and avoid pushing more than one initializer at a
1266 /// time.
1267 fn intern<K, V, T>(
1268 &mut self,
1269 key: K,
1270 map: impl Fn(&mut Self) -> &mut HashMap<K, V>,
1271 generate: impl FnOnce(&mut Self, K) -> T,
1272 init: impl FnOnce(V, T) -> GlobalInitializer,
1273 ) -> V
1274 where
1275 K: Hash + Eq + Copy,
1276 V: EntityRef,
1277 {
1278 self.intern_(key, map, generate, |me, key, val| {
1279 me.initializers.push(init(key, val));
1280 })
1281 }
1282
1283 fn intern_no_init<K, V, T>(
1284 &mut self,

Callers 6

runtime_memoryMethod · 0.45
runtime_tableMethod · 0.45
runtime_reallocMethod · 0.45
runtime_callbackMethod · 0.45
runtime_post_returnMethod · 0.45
adapter_moduleMethod · 0.45

Calls 3

intern_Method · 0.80
initFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected