Move reflect.ValueOf out of product variable loop am: 0cec312660 am: 5a9e13a2aa

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1554553

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6fce317d50a3c03ca838a9f4d2d3d943d649c8c1
This commit is contained in:
Colin Cross
2021-01-21 00:58:34 +00:00
committed by Automerger Merge Worker

View File

@@ -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
}