mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
reflect.DeepEqual is a value copy that causes golang to continuously allocate memory
This commit is contained in:
parent
893b0de8fa
commit
4e2c4f92d3
2 changed files with 11 additions and 1 deletions
|
@ -155,7 +155,7 @@ func (machine *Machine) isOnline() bool {
|
||||||
|
|
||||||
func containsAddresses(inputs []string, addrs []string) bool {
|
func containsAddresses(inputs []string, addrs []string) bool {
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
if contains(inputs, addr) {
|
if containsStr(inputs, addr) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
utils.go
10
utils.go
|
@ -269,6 +269,16 @@ func stringToIPPrefix(prefixes []string) ([]netip.Prefix, error) {
|
||||||
return result, nil
|
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 {
|
func contains[T string | netip.Prefix](ts []T, t T) bool {
|
||||||
for _, v := range ts {
|
for _, v := range ts {
|
||||||
if reflect.DeepEqual(v, t) {
|
if reflect.DeepEqual(v, t) {
|
||||||
|
|
Loading…
Reference in a new issue