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
This commit is contained in:
@@ -440,13 +440,15 @@ func VariableMutator(mctx BottomUpMutatorContext) {
|
|||||||
|
|
||||||
variableValues := reflect.ValueOf(a.variableProperties).Elem().FieldByName("Product_variables")
|
variableValues := reflect.ValueOf(a.variableProperties).Elem().FieldByName("Product_variables")
|
||||||
|
|
||||||
|
productVariables := reflect.ValueOf(mctx.Config().productVariables)
|
||||||
|
|
||||||
for i := 0; i < variableValues.NumField(); i++ {
|
for i := 0; i < variableValues.NumField(); i++ {
|
||||||
variableValue := variableValues.Field(i)
|
variableValue := variableValues.Field(i)
|
||||||
name := variableValues.Type().Field(i).Name
|
name := variableValues.Type().Field(i).Name
|
||||||
property := "product_variables." + proptools.PropertyNameForField(name)
|
property := "product_variables." + proptools.PropertyNameForField(name)
|
||||||
|
|
||||||
// Check that the variable was set for the product
|
// 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() {
|
if !val.IsValid() || val.Kind() != reflect.Ptr || val.IsNil() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user