An ActionSet doesn't need to walk the graph.
Resolutions map back to the root, but actions do not. An iteration
works just fine.
Simplify TargetNodeSet so that it is directly iterable.
Bug: 261787132
Test: m droid dist compliance_dumpgraph compliance_dumpresolutions \
compliance_sbom compliance_listshare compliance_rtrace \
compliance_checkshare xmlnotice textnotice htmlnotice \
compliancenotice_shippedlibs compliancenotice_bom
Test: m compliance_checkshare cts && \
out/host/linux-x86/bin/compliance_checkshare out/host/linux-x86/gen/META/lic_intermediates/out/host/linux-x86/cts/android-cts.zip.meta_lic
Change-Id: Ic5a2d809b5a9a47b5d85f61e3a4a790dbe8f5fd2
diff --git a/tools/compliance/graph.go b/tools/compliance/graph.go
index 80a2f47..fac1d05 100644
--- a/tools/compliance/graph.go
+++ b/tools/compliance/graph.go
@@ -459,36 +459,25 @@
}
// TargetNodeSet describes a set of distinct nodes in a license graph.
-type TargetNodeSet struct {
- nodes map[*TargetNode]struct{}
-}
+type TargetNodeSet map[*TargetNode]struct{}
// Contains returns true when `target` is an element of the set.
-func (ts *TargetNodeSet) Contains(target *TargetNode) bool {
- _, isPresent := ts.nodes[target]
+func (ts TargetNodeSet) Contains(target *TargetNode) bool {
+ _, isPresent := ts[target]
return isPresent
}
-// AsList returns the list of target nodes in the set. (unordered)
-func (ts *TargetNodeSet) AsList() TargetNodeList {
- result := make(TargetNodeList, 0, len(ts.nodes))
- for tn := range ts.nodes {
- result = append(result, tn)
- }
- return result
-}
-
// Names returns the array of target node namess in the set. (unordered)
-func (ts *TargetNodeSet) Names() []string {
- result := make([]string, 0, len(ts.nodes))
- for tn := range ts.nodes {
+func (ts TargetNodeSet) Names() []string {
+ result := make([]string, 0, len(ts))
+ for tn := range ts {
result = append(result, tn.name)
}
return result
}
// String returns a human-readable string representation of the set.
-func (ts *TargetNodeSet) String() string {
+func (ts TargetNodeSet) String() string {
return fmt.Sprintf("{%s}", strings.Join(ts.Names(), ", "))
}