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

Commit 0cec3126 authored by Colin Cross's avatar Colin Cross
Browse files

Move reflect.ValueOf out of product variable loop

Calling reflect.ValueOf for every variable for every module was
using ~3 seconds of CPU time on my AOSP builds.

Test: m checkbuild
Change-Id: Idf459ad8ddf5e07f6c0df0e58e2442aaa6ab3342
parent 324234bd
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -440,13 +440,15 @@ func VariableMutator(mctx BottomUpMutatorContext) {

	variableValues := reflect.ValueOf(a.variableProperties).Elem().FieldByName("Product_variables")

	productVariables := reflect.ValueOf(mctx.Config().productVariables)

	for i := 0; i < variableValues.NumField(); i++ {
		variableValue := variableValues.Field(i)
		name := variableValues.Type().Field(i).Name
		property := "product_variables." + proptools.PropertyNameForField(name)

		// Check that the variable was set for the product
		val := reflect.ValueOf(mctx.Config().productVariables).FieldByName(name)
		val := productVariables.FieldByName(name)
		if !val.IsValid() || val.Kind() != reflect.Ptr || val.IsNil() {
			continue
		}