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

Allow set_len(0) on an empty ThinVec. #32

Merged
merged 3 commits into from
Aug 18, 2022
Merged

Conversation

nnethercote
Copy link
Contributor

Currently it crashes.

nnethercote and others added 2 commits August 18, 2022 10:45
- Add `is_singleton`, and change the test in `set_len` to use it,
  because it's more precise than testing for zero capacity. (Precise in
  the sense of protecting against the bad case of writing to static
  memory.)
- Remove several "Don't mutate the empty singleton!" checks before
  `set_len` calls, now that `set_len` is able to handle that itself.
- Add a private `set_len_non_singleton`, and use it in places where we
  know we're not dealing with the singleton (e.g. after calling
  `reserve(1)`), for ultra-efficiency.
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

Successfully merging this pull request may close these issues.

2 participants