aboutsummaryrefslogtreecommitdiffstats
path: root/live_tracker.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2020-01-29 12:58:03 -0800
committerColin Cross <ccross@android.com>2020-01-29 16:23:40 -0800
commit2ce594e44637be0d5ad4d4f939911272fe4680aa (patch)
tree79c8831369b5ff38d6546d8f831fa77537efebd3 /live_tracker.go
parent38e095ae8a2a275909967ff8d771e59a71370505 (diff)
downloadplatform_build_blueprint-2ce594e44637be0d5ad4d4f939911272fe4680aa.tar.gz
platform_build_blueprint-2ce594e44637be0d5ad4d4f939911272fe4680aa.tar.bz2
platform_build_blueprint-2ce594e44637be0d5ad4d4f939911272fe4680aa.zip
Make ninjaString an interface
There are 8935901 *ninjaString objects generated in an AOSP aosp_blueline-userdebug build, and 7865180 of those are a literal string with no ninja variables. Each of those *ninjaString objects takes a minimum of 48 bytes for 2 slices, plus 8 bytes for the pointer to the ninjaString. For the literal string case, one of those slices has a single element, (costing another 16 bytes for the backing array), and the other slice is empty, for a total of 72 bytes. Replace *ninjaString with a ninjaString interface. This increases the size of the reference from 8 bytes to 16 bytes, but using a type alias of a string for the literal string implementation uses only 16 bytes, saving 40 bytes per literal string or 314 MB. Test: ninja_strings_test Change-Id: Ic5fe16ed1f2a244fe6a8ccdf762919634d825cbe
Diffstat (limited to 'live_tracker.go')
-rw-r--r--live_tracker.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/live_tracker.go b/live_tracker.go
index 5e13a87..40e1930 100644
--- a/live_tracker.go
+++ b/live_tracker.go
@@ -24,7 +24,7 @@ type liveTracker struct {
sync.Mutex
config interface{} // Used to evaluate variable, rule, and pool values.
- variables map[Variable]*ninjaString
+ variables map[Variable]ninjaString
pools map[Pool]*poolDef
rules map[Rule]*ruleDef
}
@@ -32,7 +32,7 @@ type liveTracker struct {
func newLiveTracker(config interface{}) *liveTracker {
return &liveTracker{
config: config,
- variables: make(map[Variable]*ninjaString),
+ variables: make(map[Variable]ninjaString),
pools: make(map[Pool]*poolDef),
rules: make(map[Rule]*ruleDef),
}
@@ -170,7 +170,7 @@ func (l *liveTracker) addVariable(v Variable) error {
return nil
}
-func (l *liveTracker) addNinjaStringListDeps(list []*ninjaString) error {
+func (l *liveTracker) addNinjaStringListDeps(list []ninjaString) error {
for _, str := range list {
err := l.addNinjaStringDeps(str)
if err != nil {
@@ -180,8 +180,8 @@ func (l *liveTracker) addNinjaStringListDeps(list []*ninjaString) error {
return nil
}
-func (l *liveTracker) addNinjaStringDeps(str *ninjaString) error {
- for _, v := range str.variables {
+func (l *liveTracker) addNinjaStringDeps(str ninjaString) error {
+ for _, v := range str.Variables() {
err := l.addVariable(v)
if err != nil {
return err