From 67d8ae390a04840d647fd95457c2ad91c732b1c7 Mon Sep 17 00:00:00 2001 From: Bob Badour Date: Mon, 10 Jan 2022 18:32:54 -0800 Subject: [PATCH] Fold annotations. Use annotation slices looked up from map instead of read from disk to reduce copies. 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: Ibf6f7d319092e0d54ab451ffbbd35dcd7d0080e0 --- tools/compliance/policy/policy.go | 9 +++++++++ tools/compliance/readgraph.go | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/compliance/policy/policy.go b/tools/compliance/policy/policy.go index 9dab05bbf0..d3e412b84e 100644 --- a/tools/compliance/policy/policy.go +++ b/tools/compliance/policy/policy.go @@ -20,6 +20,15 @@ import ( ) var ( + // RecognizedAnnotations identifies the set of annotations that have + // meaning for compliance policy. + RecognizedAnnotations = map[string]string{ + // used in readgraph.go to avoid creating 1000's of copies of the below 3 strings. + "static": "static", + "dynamic": "dynamic", + "toolchain": "toolchain", + } + // ImpliesUnencumbered lists the condition names representing an author attempt to disclaim copyright. ImpliesUnencumbered = ConditionNames{"unencumbered"} diff --git a/tools/compliance/readgraph.go b/tools/compliance/readgraph.go index 45fa1343ba..face775479 100644 --- a/tools/compliance/readgraph.go +++ b/tools/compliance/readgraph.go @@ -188,10 +188,11 @@ func addDependencies(edges *[]*dependencyEdge, target string, dependencies []*li } annotations := newEdgeAnnotations() for _, a := range ad.Annotations { - if len(a) == 0 { - continue + // look up a common constant annotation string from a small map + // instead of creating 1000's of copies of the same 3 strings. + if ann, ok := RecognizedAnnotations[a]; ok { + annotations.annotations[ann] = true } - annotations.annotations[a] = true } *edges = append(*edges, &dependencyEdge{target, dependency, annotations}) }