Skip to content

Commit 1cd0f3b

Browse files
Mauricio GomesMauricio Gomes
authored andcommitted
Skip rescans for capability scopes without contracts
1 parent 38d676c commit 1cd0f3b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

vibes/execution.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ func (exec *Execution) invokeCallable(callee Value, receiver Value, args []Value
631631
}
632632
}
633633
scope := exec.capabilityContractScopes[builtin]
634-
if scope != nil {
634+
if scope != nil && len(scope.contracts) > 0 {
635635
// Capability methods can lazily publish additional builtins at runtime
636636
// (e.g. through factory return values or receiver mutation). Re-scan
637637
// these values so future calls still enforce declared contracts.
@@ -3460,7 +3460,9 @@ func (s *Script) Call(ctx context.Context, name string, args []Value, opts CallO
34603460
for name, val := range globals {
34613461
rebound := rebinder.rebindValue(val)
34623462
root.Define(name, rebound)
3463-
scope.roots = append(scope.roots, rebound)
3463+
if len(scope.contracts) > 0 {
3464+
scope.roots = append(scope.roots, rebound)
3465+
}
34643466
bindCapabilityContracts(rebound, scope, exec.capabilityContracts, exec.capabilityContractScopes)
34653467
}
34663468
}

0 commit comments

Comments
 (0)