Skip to content

Commit

Permalink
minor internal rewording
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Apr 24, 2024
1 parent 7ee68e9 commit ea5deac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions stringify.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,24 @@ func (n *node[V]) getKidsRec(parentIdx uint, path []byte, is4 bool) []kidT[V] {
return directKids
}

// cidrFromPath, make prefix from byte path, next octet (byte, stride) and pfxLen.
// cidrFromPath, make prefix from byte path, next octet and pfxLen.
func cidrFromPath(path []byte, idx uint, is4 bool) (pfx netip.Prefix) {
octet, pfxLen := baseIndexToPrefix(idx)

// append last (partially) masked byte to path and
// calc bits with pathLen and pfxLen
bs := append(slices.Clone(path), octet)
octets := append(slices.Clone(path), octet)
bits := len(path)*strideLen + pfxLen

// make ip addr from octets
var ip netip.Addr
if is4 {
b4 := [4]byte{}
copy(b4[:], bs)
copy(b4[:], octets)
ip = netip.AddrFrom4(b4)
} else {
b16 := [16]byte{}
copy(b16[:], bs)
copy(b16[:], octets)
ip = netip.AddrFrom16(b16)
}

Expand Down
2 changes: 1 addition & 1 deletion table.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ func (t *Table[V]) Clone() *Table[V] {
// Prefixes must not be inserted or deleted by the callback function, otherwise
// the behavior is undefined. However, value updates are permitted.
//
// The sort order is not specified and is not part of the
// The walk order is not specified and is not part of the
// public interface, you must not rely on it.
func (t *Table[V]) Walk(cb func(pfx netip.Prefix, val V) error) error {
t.init()
Expand Down

0 comments on commit ea5deac

Please sign in to comment.