@@ -612,7 +612,7 @@ func (n *nodeContext) hasEvidenceForAll(a reqSets, conjuncts []conjunctInfo) boo
612
612
continue
613
613
}
614
614
615
- if ! hasEvidenceForOne (a , i , conjuncts ) {
615
+ if ! n . hasEvidenceForOne (a , i , conjuncts ) {
616
616
if n .ctx .LogEval > 0 {
617
617
n .Logf ("DENIED BY %d" , a [i ].id )
618
618
}
@@ -624,14 +624,12 @@ func (n *nodeContext) hasEvidenceForAll(a reqSets, conjuncts []conjunctInfo) boo
624
624
625
625
// hasEvidenceForOne reports whether a single typo-checked set has evidence for
626
626
// any of its defIDs.
627
- func hasEvidenceForOne (all reqSets , i uint32 , conjuncts []conjunctInfo ) bool {
627
+ func ( n * nodeContext ) hasEvidenceForOne (all reqSets , i uint32 , conjuncts []conjunctInfo ) bool {
628
628
a := all [i : i + all [i ].size ]
629
629
630
- for _ , c := range conjuncts {
631
- for _ , ri := range a {
632
- if c .id == ri .id {
633
- return true
634
- }
630
+ for _ , x := range conjuncts {
631
+ if n .containsDefID (requirement (a ), x .id ) {
632
+ return true
635
633
}
636
634
}
637
635
@@ -649,11 +647,9 @@ func hasEvidenceForOne(all reqSets, i uint32, conjuncts []conjunctInfo) bool {
649
647
650
648
outer:
651
649
for _ , c := range conjuncts {
652
- for _ , x := range embedScope {
653
- if x .id == c .embed {
654
- // Within the scope of the embedding.
655
- continue outer
656
- }
650
+ if n .containsDefID (requirement (embedScope ), c .embed ) {
651
+ // Within the scope of the embedding.
652
+ continue outer
657
653
}
658
654
659
655
if len (outerScope ) == 0 || a [0 ].parent == 0 {
@@ -663,10 +659,17 @@ outer:
663
659
// If this conjunct is within the outer struct, but outside the
664
660
// embedding scope, this means it was "added" and we do not have
665
661
// to verify it within the embedding scope.
666
- for _ , x := range outerScope {
667
- if x .id == c .id {
668
- return true
669
- }
662
+ if n .containsDefID (requirement (outerScope ), c .id ) {
663
+ return true
664
+ }
665
+ }
666
+ return false
667
+ }
668
+
669
+ func (n * nodeContext ) containsDefID (node requirement , child defID ) bool {
670
+ for _ , ri := range node {
671
+ if child == ri .id {
672
+ return true
670
673
}
671
674
}
672
675
return false
@@ -957,10 +960,8 @@ outer:
957
960
if allowedInClosed (v .Label ) {
958
961
n .filterSets (& a , func (n * nodeContext , a requirement ) bool {
959
962
for _ , c := range n .conjunctInfo {
960
- for _ , e := range a {
961
- if c .id == e .id {
962
- return true // keep the set
963
- }
963
+ if n .containsDefID (requirement (a ), c .id ) {
964
+ return true // keep the set
964
965
}
965
966
}
966
967
return false // discard the set
@@ -986,10 +987,7 @@ func (n *nodeContext) filterTop(a *reqSets, conjuncts, parentConjuncts []conjunc
986
987
var f conjunctFlags
987
988
hasAny := false
988
989
for _ , c := range conjuncts {
989
- for _ , e := range a {
990
- if e .id != c .id {
991
- continue
992
- }
990
+ if n .containsDefID (requirement (a ), c .id ) {
993
991
hasAny = true
994
992
flags := c .flags
995
993
if c .id < a [0 ].id {
@@ -1020,10 +1018,8 @@ func hasParentEllipsis(n *nodeContext, a requirement, conjuncts []conjunctInfo)
1020
1018
if ! c .flags .hasEllipsis () {
1021
1019
continue
1022
1020
}
1023
- for _ , e := range a {
1024
- if e .id == c .id {
1025
- return true
1026
- }
1021
+ if n .containsDefID (requirement (a ), c .id ) {
1022
+ return true
1027
1023
}
1028
1024
}
1029
1025
return false
0 commit comments