net/art: move slice closer to its use

Updates #7781

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson 2023-07-24 12:07:25 -07:00 committed by Dave Anderson
parent 44ad7b3746
commit f1cd67488d

View File

@ -166,13 +166,11 @@ func (t *Table[T]) Insert(pfx netip.Prefix, val *T) {
return return
} }
bs := pfx.Addr().AsSlice()
// No matter what we do as we traverse strideTables, our final // No matter what we do as we traverse strideTables, our final
// action will be to insert the last 1-8 bits of pfx into a // action will be to insert the last 1-8 bits of pfx into a
// strideTable somewhere. // strideTable somewhere.
// //
// We calculate upfront the byte position in bs of the end of the // We calculate upfront the byte position of the end of the
// prefix; the number of bits within that byte that contain prefix // prefix; the number of bits within that byte that contain prefix
// data; and the prefix of the strideTable into which we'll // data; and the prefix of the strideTable into which we'll
// eventually insert. // eventually insert.
@ -205,6 +203,7 @@ func (t *Table[T]) Insert(pfx netip.Prefix, val *T) {
// currently examining to choose our next step, and numBits is the // currently examining to choose our next step, and numBits is the
// number of bits that remain in pfx, starting with the byte at // number of bits that remain in pfx, starting with the byte at
// byteIdx inclusive. // byteIdx inclusive.
bs := pfx.Addr().AsSlice()
byteIdx := 0 byteIdx := 0
numBits := pfx.Bits() numBits := pfx.Bits()
for { for {