utils.go: Removed CloneMap(). fromGenericAny(): check v against nil
This commit is contained in:
parent
b9e780e659
commit
0760141caf
44
utils.go
44
utils.go
@ -135,23 +135,25 @@ 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 exprAny, ok = v.(bool); ok {
|
if v != nil {
|
||||||
return
|
if exprAny, ok = v.(bool); ok {
|
||||||
}
|
return
|
||||||
if exprAny, ok = v.(string); ok {
|
}
|
||||||
return
|
if exprAny, ok = v.(string); ok {
|
||||||
}
|
return
|
||||||
if exprAny, ok = anyInteger(v); ok {
|
}
|
||||||
return
|
if exprAny, ok = anyInteger(v); ok {
|
||||||
}
|
return
|
||||||
if exprAny, ok = anyFloat(v); ok {
|
}
|
||||||
return
|
if exprAny, ok = anyFloat(v); ok {
|
||||||
}
|
return
|
||||||
if exprAny, ok = v.(*DictType); ok {
|
}
|
||||||
return
|
if exprAny, ok = v.(*DictType); ok {
|
||||||
}
|
return
|
||||||
if exprAny, ok = v.(*ListType); ok {
|
}
|
||||||
return
|
if exprAny, ok = v.(*ListType); ok {
|
||||||
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user