-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2024 Karl Gaissmaier | ||
// SPDX-License-Identifier: MIT | ||
|
||
package bart | ||
|
||
import "github.com/bits-and-blooms/bitset" | ||
|
||
// allotedPrefixRoutes, overwrite the buffer with the precalculated words in allotment table. | ||
func allotedPrefixRoutes(idx uint, buf []uint64) { | ||
if idx < 256 { | ||
// overwrite the backing array of bitset with precalculated bitset | ||
copy(buf[:], allotLookupTbl[idx][:]) | ||
return | ||
} | ||
// upper half in allot tbl, just 1 bit is set, fast calculation at runtime | ||
bitset.From(buf[:]).Set(idx) | ||
} | ||
|
||
// allotedHostRoutes, overwrite the buffer with the precalculated words in allotment table. | ||
func allotedHostRoutes(idx uint, buf []uint64) { | ||
if idx < 256 { | ||
// overwrite the backing array of bitset with precalculated bitset | ||
copy(buf[:], allotLookupTbl[idx][4:]) | ||
return | ||
} | ||
// upper half in allot tbl, just 1 bit is set, fast calculation at runtime | ||
bitset.From(buf[:]).Set(idx - 256) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Copyright (c) 2024 Karl Gaissmaier | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:build !big_endian | ||
|
||
package bart | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters