MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / result_memoizable

Function result_memoizable

compiler/src/modules/vm/cache.rs:232–236  ·  view source on GitHub ↗

Memoize only immediates (int/float/bool/None) and immutable heap objects; fresh mutable containers or tuples/sets wrapping them must stay per-call to avoid aliasing and falsifying `is`. */

(result: Val, heap: &super::types::HeapPool)

Source from the content-addressed store, hash-verified

230
231/* Memoize only immediates (int/float/bool/None) and immutable heap objects; fresh mutable containers or tuples/sets wrapping them must stay per-call to avoid aliasing and falsifying `is`. */
232fn result_memoizable(result: Val, heap: &super::types::HeapPool) -> bool {
233 use super::types::HeapObj;
234 if !result.is_heap() { return true; }
235 matches!(heap.try_get(result), Some(HeapObj::Str(_) | HeapObj::Bytes(_) | HeapObj::LongInt(_)))
236}
237
238// Indexed by dense `fi`; Vec gives O(1) lookup with no HashMap monomorphization.
239pub struct Templates { slots: Vec<Vec<TplEntry>> }

Callers 1

recordMethod · 0.85

Calls 1

is_heapMethod · 0.80

Tested by

no test coverage detected