Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce stack which recycles the entries #145

Open
overlookmotel opened this issue Nov 17, 2024 · 0 comments
Open

Introduce stack which recycles the entries #145

overlookmotel opened this issue Nov 17, 2024 · 0 comments

Comments

@overlookmotel
Copy link

overlookmotel commented Nov 17, 2024

Semantic includes a stack structure UnresolvedReferencesStack which stores a bunch of hash maps and recycles them as go up and down the stack.

Generalize this to a NonEmptyRecycleStack structure, which we can also use in many places in transformer.

Additionally, optimize it by using pointers instead of len + capacity, the same way Stack and NonEmptyStack do:

pub struct NonEmptyRecycleStack<T: Default> {
    /// Pointer to current entry on stack.
    /// Points *to* current entry, not *after* current entry.
    cursor: NonNull<T>,
    /// Pointer to start of allocation (first entry)
    start: NonNull<T>,
    /// Pointer to after last filled slot
    end_filled: NonNull<T>,
    /// Pointer to end of allocation
    end: NonNull<T>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant