internal/core/adt: fix memory leak

Also includes some minimal cleanup.

Change-Id: Ie84784a1f6c7137805d6d1461f46d3aee157bfcd
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8285
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
diff --git a/internal/core/adt/eval.go b/internal/core/adt/eval.go
index d09a5c2..ffa4b56 100644
--- a/internal/core/adt/eval.go
+++ b/internal/core/adt/eval.go
@@ -392,20 +392,21 @@
 }
 
 func (n *nodeContext) doNotify() {
-	if n.errs != nil && len(n.notify) > 0 {
-		for _, v := range n.notify {
-			if v.state == nil {
-				if b, ok := v.BaseValue.(*Bottom); ok {
-					v.BaseValue = CombineErrors(nil, b, n.errs)
-				} else {
-					v.BaseValue = n.errs
-				}
-			} else {
-				v.state.addBottom(n.errs)
-			}
-		}
-		n.notify = n.notify[:0]
+	if n.errs == nil || len(n.notify) == 0 {
+		return
 	}
+	for _, v := range n.notify {
+		if v.state == nil {
+			if b, ok := v.BaseValue.(*Bottom); ok {
+				v.BaseValue = CombineErrors(nil, b, n.errs)
+			} else {
+				v.BaseValue = n.errs
+			}
+		} else {
+			v.state.addBottom(n.errs)
+		}
+	}
+	n.notify = n.notify[:0]
 }
 
 func isStruct(v *Vertex) bool {
@@ -774,6 +775,7 @@
 			node:          node,
 			kind:          TopKind,
 			arcMap:        n.arcMap[:0],
+			notify:        n.notify[:0],
 			checks:        n.checks[:0],
 			dynamicFields: n.dynamicFields[:0],
 			ifClauses:     n.ifClauses[:0],