Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0cec59e1 authored by Colin Cross's avatar Colin Cross Committed by Luca Stefani
Browse files

Optimize getJarJarRuleText

getJarJarRuleText accounted for 10% of all allocations in Soong totalling
10 GB due to repeated string growth.  Use a StringBuilder instead.

Test: builds
Change-Id: I4bce338d161cb2f9c0aba1036ced55d2e8ee6b14
parent 3e8d483b
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -2933,14 +2933,18 @@ func (module *Module) collectJarJarRules(ctx android.ModuleContext) *JarJarProvi
// Get the jarjar rule text for a given provider for the fully resolved rules. Classes that map
// to "" won't be in this list because they shouldn't be renamed yet.
func getJarJarRuleText(provider *JarJarProviderData) string {
	result := ""
	result := strings.Builder{}
	for _, orig := range android.SortedKeys(provider.Rename) {
		renamed := provider.Rename[orig]
		if renamed != "" {
			result += "rule " + orig + " " + renamed + "\n"
			result.WriteString("rule ")
			result.WriteString(orig)
			result.WriteString(" ")
			result.WriteString(renamed)
			result.WriteString("\n")
		}
	}
	return result
	return result.String()
}

// Repackage the flags if the jarjar rule txt for the flags is generated