-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use const generics to remove BitTree heap allocations
The single-argument that BitTree takes is 1 << NUM_BITS (2 ** NUM_BITS) for the number of bits required in the tree. This is due to restrictions on const generic expressions. The validity of this argument is checked at compile-time with a macro that confirms that the argument P passed is indeed 1 << N for some N using usize::trailing_zeros to calculate floor(log_2(P)). Thus, BitTree<const P: usize> is only valid for any P such that P = 2 ** floor(log_2(P)), where P is the length of the probability array of the BitTree. This maintains the invariant that P = 1 << N.
- Loading branch information
Showing
7 changed files
with
197 additions
and
115 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
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
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
Oops, something went wrong.