From 62496a0d2eabf72d6f8b3b99a5e87559c9bfd85d Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 8 Aug 2016 15:49:17 -0700 Subject: [PATCH] Use nil pointers for arch property structs Blueprint can now handle creating a zero-valued struct when it encounters a nil pointer to a struct, reducing the amount of allocations and copying for arch structures that are not used. Change-Id: If36da5603dbe6469fe6406c821f21a122ea6ea49 --- android/arch.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/android/arch.go b/android/arch.go index d6b28363b..fde106d82 100644 --- a/android/arch.go +++ b/android/arch.go @@ -463,6 +463,7 @@ func InitArchModule(m Module, for _, properties := range base.generalProperties { propertiesValue := reflect.ValueOf(properties) + t := propertiesValue.Type() if propertiesValue.Kind() != reflect.Ptr { panic(fmt.Errorf("properties must be a pointer to a struct, got %T", propertiesValue.Interface())) @@ -476,7 +477,7 @@ func InitArchModule(m Module, archProperties := &archProperties{} forEachInterface(reflect.ValueOf(archProperties), func(v reflect.Value) { - newValue := proptools.CloneEmptyProperties(propertiesValue) + newValue := reflect.Zero(t) v.Set(newValue) })