-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(transformer): introduce
Stack
(#6093)
`Stack` is a stack structure, optimized for fast push/pop and reading/writing the last entry on the stack. The difference from `NonEmptyStack` is that it can be empty. This has a different trade-off vs `NonEmptyStack`: * `Stack::new` does not allocate (`NonEmptyStack` does). * `Stack::last` and `Stack::last_mut` are fallible and contain a branch (those methods on `NonEmptyStack` are branchless and infallible). `Stack` is only the better choice if: 1. You want `new()` not to allocate. or 2. Creating initial value for `NonEmptyStack::new()` is expensive. Use `Stack` as one of the backing stores in `SparseStack`.
- Loading branch information
1 parent
ad4ef31
commit 85aff19
Showing
4 changed files
with
679 additions
and
9 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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
mod capacity; | ||
mod non_empty; | ||
mod sparse; | ||
mod standard; | ||
|
||
use capacity::StackCapacity; | ||
pub use non_empty::NonEmptyStack; | ||
pub use sparse::SparseStack; | ||
pub use standard::Stack; |
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.