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/policy/resolve.go b/tools/compliance/policy/resolve.go
index 58547f8..c107520 100644
--- a/tools/compliance/policy/resolve.go
+++ b/tools/compliance/policy/resolve.go
@@ -83,7 +83,7 @@
rmap := make(map[*TargetNode]actionSet)
// cmap contains the set of targets walked as pure aggregates. i.e. containers
- cmap := make(map[*TargetNode]bool)
+ cmap := make(map[*TargetNode]struct{})
var walk func(fnode *TargetNode, cs *LicenseConditionSet, treatAsAggregate bool)
@@ -93,7 +93,7 @@
}
rmap[fnode].add(fnode, cs)
if treatAsAggregate {
- cmap[fnode] = true
+ cmap[fnode] = struct{}{}
}
// add conditions attached to `fnode`
cs = cs.Copy()
@@ -179,7 +179,7 @@
rs := newResolutionSet()
// cmap contains an entry for every target that was previously walked as a pure aggregate only.
- cmap := make(map[string]bool)
+ cmap := make(map[string]struct{})
var walk func(f string, treatAsAggregate bool) actionSet
@@ -205,7 +205,7 @@
delete(cmap, f)
}
if treatAsAggregate {
- cmap[f] = true
+ cmap[f] = struct{}{}
}
// add all the conditions from all the dependencies