all: use bart.Lite instead of bart.Table where appropriate
When we don't care about the payload value and are just checking whether a set contains an IP/prefix, we can use `bart.Lite` for the same lookup times but a lower memory footprint. Fixes #19075 Change-Id: Ia709e8b718666cc61ea56eac1066467ae0b6e86c Signed-off-by: Alex Chan <alexc@tailscale.com>
This commit is contained in:
@@ -101,7 +101,7 @@ var (
|
||||
appleIPRange = netip.MustParsePrefix("17.0.0.0/8")
|
||||
canonicalIPs = sync.OnceValue(func() (checkIPFunc func(netip.Addr) bool) {
|
||||
// https://bgp.he.net/AS41231#_prefixes
|
||||
t := &bart.Table[bool]{}
|
||||
t := &bart.Lite{}
|
||||
for s := range strings.FieldsSeq(`
|
||||
91.189.89.0/24
|
||||
91.189.91.0/24
|
||||
@@ -115,12 +115,9 @@ var (
|
||||
185.125.188.0/23
|
||||
185.125.190.0/24
|
||||
194.169.254.0/24`) {
|
||||
t.Insert(netip.MustParsePrefix(s), true)
|
||||
}
|
||||
return func(ip netip.Addr) bool {
|
||||
v, _ := t.Lookup(ip)
|
||||
return v
|
||||
t.Insert(netip.MustParsePrefix(s))
|
||||
}
|
||||
return t.Contains
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user