diff options
| author | 2021-01-20 11:27:32 -0800 | |
|---|---|---|
| committer | 2021-01-20 19:32:42 +0000 | |
| commit | 0cec312660f7747a8b69e2fcae9c574f4edd1c4c (patch) | |
| tree | 2929cfc4034cce18867b46d96e11c51ebe607872 /android/variable.go | |
| parent | 324234bd0007ebc78843eece46bb7e8d337e8026 (diff) | |
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
Diffstat (limited to 'android/variable.go')
| -rw-r--r-- | android/variable.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/android/variable.go b/android/variable.go index 73be7a03a..9b3ed1765 100644 --- a/android/variable.go +++ b/android/variable.go @@ -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 } |