Skip to content

Commit 39e88fc

Browse files
committed
avoid all allocations if no arguments are needed
1 parent d030d1e commit 39e88fc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

vm/vm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,10 @@ func (vm *VM) scope() *Scope {
602602
// reverse order. Because the estimation can fall short, this function can
603603
// occasionally make a new allocation.
604604
func (vm *VM) getArgsForFunc(bufPtr *[]any, program *Program, needed int) []any {
605+
if needed == 0 || bufPtr == nil && program == nil {
606+
return nil
607+
}
608+
605609
// Step 1: fix estimations and preallocate
606610
if *bufPtr == nil {
607611
estimatedFnArgsCount := estimateFnArgsCount(program)

0 commit comments

Comments
 (0)