MCPcopy
hub / github.com/expr-lang/expr / allocScope

Method allocScope

vm/vm.go:700–718  ·  view source on GitHub ↗

allocScope returns a pointer to a Scope from the pool, growing the pool if needed. Callers must set Len and exactly one of: Ints, Floats, Strings, Anys, or Array.

()

Source from the content-addressed store, hash-verified

698// allocScope returns a pointer to a Scope from the pool, growing the pool if needed.
699// Callers must set Len and exactly one of: Ints, Floats, Strings, Anys, or Array.
700func (vm *VM) allocScope() *Scope {
701 if vm.scopePoolIdx >= len(vm.scopePool) {
702 vm.scopePool = append(vm.scopePool, Scope{})
703 }
704 s := &vm.scopePool[vm.scopePoolIdx]
705 vm.scopePoolIdx++
706 // Reset iteration state
707 s.Index = 0
708 s.Count = 0
709 s.Acc = nil
710 // Clear typed slice pointers to avoid stale fast-path matches
711 s.Ints = nil
712 s.Floats = nil
713 s.Strings = nil
714 s.Anys = nil
715 // Clear Array to release reference for GC (only matters for fallback path)
716 s.Array = reflect.Value{}
717 return s
718}
719
720// getArgsForFunc lazily initializes the buffer the first time it is called for
721// a given program (thus, it also needs "program" to run). It will

Callers 1

RunMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected