utils.go: Removed CloneMap(). fromGenericAny(): check v against nil

This commit is contained in:
Celestino Amoroso 2024-06-25 10:48:31 +02:00
parent b9e780e659
commit 0760141caf

View File

@ -135,6 +135,7 @@ func anyInteger(v any) (i int64, ok bool) {
} }
func fromGenericAny(v any) (exprAny any, ok bool) { func fromGenericAny(v any) (exprAny any, ok bool) {
if v != nil {
if exprAny, ok = v.(bool); ok { if exprAny, ok = v.(bool); ok {
return return
} }
@ -153,6 +154,7 @@ func fromGenericAny(v any) (exprAny any, ok bool) {
if exprAny, ok = v.(*ListType); ok { if exprAny, ok = v.(*ListType); ok {
return return
} }
}
return return
} }
@ -176,10 +178,10 @@ func CopyMap[K comparable, V any](dest, source map[K]V) map[K]V {
return dest return dest
} }
func CloneMap[K comparable, V any](source map[K]V) map[K]V { // func CloneMap[K comparable, V any](source map[K]V) map[K]V {
dest := make(map[K]V, len(source)) // dest := make(map[K]V, len(source))
return CopyMap(dest, source) // return CopyMap(dest, source)
} // }
func CopyFilteredMap[K comparable, V any](dest, source map[K]V, filter func(key K) (accept bool)) map[K]V { func CopyFilteredMap[K comparable, V any](dest, source map[K]V, filter func(key K) (accept bool)) map[K]V {
// fmt.Printf("--- Clone with filter %p\n", filter) // fmt.Printf("--- Clone with filter %p\n", filter)