Use struct{}
Using struct{}{} as the payload for set maps reduces memory use for
large sets.
Bug: 68860345
Bug: 151177513
Bug: 151953481
Test: m all
Test: m systemlicense
Test: m listshare; out/soong/host/linux-x86/bin/listshare ...
Test: m checkshare; out/soong/host/linux-x86/bin/checkshare ...
Test: m dumpgraph; out/soong/host/linux-x86/dumpgraph ...
Test: m dumpresolutions; out/soong/host/linux-x86/dumpresolutions ...
where ... is the path to the .meta_lic file for the system image. In my
case if
$ export PRODUCT=$(realpath $ANDROID_PRODUCT_OUT --relative-to=$PWD)
... can be expressed as:
${PRODUCT}/gen/META/lic_intermediates/${PRODUCT}/system.img.meta_lic
Change-Id: Ibc831ae80fc50f35e1000348fb28fc0167d0ebed
diff --git a/tools/compliance/resolutionset.go b/tools/compliance/resolutionset.go
index ea49db9..29f3212 100644
--- a/tools/compliance/resolutionset.go
+++ b/tools/compliance/resolutionset.go
@@ -117,10 +117,10 @@
// ActsOn identifies the list of targets to act on (share, give notice etc.)
// to resolve conditions. (unordered)
func (rs *ResolutionSet) ActsOn() TargetNodeList {
- tset := make(map[*TargetNode]bool)
+ tset := make(map[*TargetNode]struct{})
for _, as := range rs.resolutions {
for actsOn := range as {
- tset[actsOn] = true
+ tset[actsOn] = struct{}{}
}
}
targets := make(TargetNodeList, 0, len(tset))
@@ -133,12 +133,12 @@
// Origins identifies the list of targets originating conditions to resolve.
// (unordered)
func (rs *ResolutionSet) Origins() TargetNodeList {
- tset := make(map[*TargetNode]bool)
+ tset := make(map[*TargetNode]struct{})
for _, as := range rs.resolutions {
for _, cs := range as {
for _, origins := range cs.conditions {
for origin := range origins {
- tset[origin] = true
+ tset[origin] = struct{}{}
}
}
}
@@ -189,11 +189,11 @@
// AttachesToByOrigin identifies the list of targets requiring action to
// resolve conditions originating at `origin`. (unordered)
func (rs *ResolutionSet) AttachesToByOrigin(origin *TargetNode) TargetNodeList {
- tset := make(map[*TargetNode]bool)
+ tset := make(map[*TargetNode]struct{})
for attachesTo, as := range rs.resolutions {
for _, cs := range as {
if cs.HasAnyByOrigin(origin) {
- tset[attachesTo] = true
+ tset[attachesTo] = struct{}{}
break
}
}