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
This commit is contained in:
Bob Badour
2022-12-18 14:15:02 -08:00
parent 42b02efd05
commit 3fe369c271
4 changed files with 18 additions and 53 deletions

View File

@@ -459,36 +459,25 @@ func (ea TargetEdgeAnnotations) AsList() []string {
}
// 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(), ", "))
}