2
0

AssignTo pointer to pointer to slice and named types

fixes #69
This commit is contained in:
Jack Christensen
2020-10-24 09:21:42 -05:00
parent 9639a69d45
commit 9d7fc8e63a
24 changed files with 120 additions and 144 deletions
+5 -6
View File
@@ -221,6 +221,11 @@ func (src *Float4Array) AssignTo(dst interface{}) error {
}
}
// Try to convert to something AssignTo can use directly.
if nextDst, retry := GetAssignToDstType(dst); retry {
return src.AssignTo(nextDst)
}
// Fallback to reflection if an optimised match was not found.
// The reflection is necessary for arrays and multidimensional slices,
// but it comes with a 20-50% performance penalty for large arrays/slices
@@ -228,12 +233,6 @@ func (src *Float4Array) AssignTo(dst interface{}) error {
if value.Kind() == reflect.Ptr {
value = value.Elem()
}
if !value.CanSet() {
if nextDst, retry := GetAssignToDstType(dst); retry {
return src.AssignTo(nextDst)
}
return errors.Errorf("unable to assign to %T", dst)
}
elementCount, err := src.assignToRecursive(value, 0, 0)
if err != nil {