From 4a57024b94edf23a20f1e4289052d0717227683b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 3 Jun 2021 13:51:03 +0200 Subject: device: reduce size of trie struct Signed-off-by: Jason A. Donenfeld --- device/allowedips_rand_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'device/allowedips_rand_test.go') diff --git a/device/allowedips_rand_test.go b/device/allowedips_rand_test.go index bb3fb43..2da8795 100644 --- a/device/allowedips_rand_test.go +++ b/device/allowedips_rand_test.go @@ -19,7 +19,7 @@ const ( type SlowNode struct { peer *Peer - cidr uint + cidr uint8 bits []byte } @@ -37,7 +37,7 @@ func (r SlowRouter) Swap(i, j int) { r[i], r[j] = r[j], r[i] } -func (r SlowRouter) Insert(addr []byte, cidr uint, peer *Peer) SlowRouter { +func (r SlowRouter) Insert(addr []byte, cidr uint8, peer *Peer) SlowRouter { for _, t := range r { if t.cidr == cidr && commonBits(t.bits, addr) >= cidr { t.peer = peer @@ -80,7 +80,7 @@ func TestTrieRandomIPv4(t *testing.T) { for n := 0; n < NumberOfAddresses; n++ { var addr [AddressLength]byte rand.Read(addr[:]) - cidr := uint(rand.Uint32() % (AddressLength * 8)) + cidr := uint8(rand.Uint32() % (AddressLength * 8)) index := rand.Int() % NumberOfPeers trie = trie.insert(addr[:], cidr, peers[index]) slow = slow.Insert(addr[:], cidr, peers[index]) @@ -113,7 +113,7 @@ func TestTrieRandomIPv6(t *testing.T) { for n := 0; n < NumberOfAddresses; n++ { var addr [AddressLength]byte rand.Read(addr[:]) - cidr := uint(rand.Uint32() % (AddressLength * 8)) + cidr := uint8(rand.Uint32() % (AddressLength * 8)) index := rand.Int() % NumberOfPeers trie = trie.insert(addr[:], cidr, peers[index]) slow = slow.Insert(addr[:], cidr, peers[index]) -- cgit v1.2.3-59-g8ed1b