mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-23 10:05:19 +00:00
reflect.DeepEqual is a value copy that causes golang to continuously allocate memory
This commit is contained in:
parent
893b0de8fa
commit
4e2c4f92d3
@ -155,7 +155,7 @@ func (machine *Machine) isOnline() bool {
|
||||
|
||||
func containsAddresses(inputs []string, addrs []string) bool {
|
||||
for _, addr := range addrs {
|
||||
if contains(inputs, addr) {
|
||||
if containsStr(inputs, addr) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
10
utils.go
10
utils.go
@ -269,6 +269,16 @@ func stringToIPPrefix(prefixes []string) ([]netip.Prefix, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func containsStr(ts []string, t string) bool {
|
||||
for _, v := range ts {
|
||||
if v == t {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func contains[T string | netip.Prefix](ts []T, t T) bool {
|
||||
for _, v := range ts {
|
||||
if reflect.DeepEqual(v, t) {
|
||||
|
Loading…
Reference in New Issue
Block a user