about summary refs log tree commit diff
path: root/src/liballoc/raw_vec.rs
AgeCommit message (Collapse)AuthorLines
2020-05-20Adjust the zero check in `RawVec::grow`.Nicholas Nethercote-4/+3
This was supposed to land as part of #72227. (I wish `git push` would abort when you have uncommited changes.)
2020-05-18Tiny Vecs are dumb.Nicholas Nethercote-4/+25
Currently, if you repeatedly push to an empty vector, the capacity growth sequence is 0, 1, 2, 4, 8, 16, etc. This commit changes the relevant code (the "amortized" growth strategy) to skip 1 and 2 in most cases, instead using 0, 4, 8, 16, etc. (You can still get a capacity of 1 or 2 using the "exact" growth strategy, e.g. via `reserve_exact()`.) This idea (along with the phrase "tiny Vecs are dumb") comes from the "doubling" growth strategy that was removed from `RawVec` in #72013. That strategy was barely ever used -- only when a `VecDeque` was grown, oddly enough -- which is why it was removed in #72013. (Fun fact: until just a few days ago, I thought the "doubling" strategy was used for repeated push case. In other words, this commit makes `Vec`s behave the way I always thought they behaved.) This change reduces the number of allocations done by rustc itself by 10% or more. It speeds up rustc, and will also speed up any other Rust program that uses `Vec`s a lot.
2020-05-12Split `RawVec::grow` up.Nicholas Nethercote-50/+79
The amortized case is much more common than the exact case, and it is typically instantiated many times. Also, we can put a chunk of the code into a function that isn't generic over T, which reduces the amount of LLVM IR generated quite a lot, improving compile times.
2020-05-12Remove `RawVec::double`.Nicholas Nethercote-82/+9
It's only used once, for `VecDeque`, and can easily be replaced by something else. The commit changes `grow_if_necessary` to `grow` to avoid some small regressions caused by changed inlining. The commit also removes `Strategy::Double`, and streamlines the remaining variants of `Strategy`. It's a compile time win on some benchmarks because the many instantations of `RawVec::grow` are a little smaller.
2020-05-12Remove `RawVec::double_in_place`.Nicholas Nethercote-18/+0
It's unused.
2020-04-30rename-unique: Rename Unique::empty() to Unique::dangling()cohenarthur-5/+5
rename-unique: Change calls and doc in raw_vec.rs rename-unique: Change empty() -> dangling() in const-ptr-unique-rpass.rs
2020-04-26remove Unique::from for shared pointer typesRalf Jung-2/+2
2020-04-06Use usize::MAX as assoc const in liballocLinus Färnstrand-1/+1
2020-04-05clarify safety in RawVec::into_boxRalf Jung-3/+6
2020-04-04use ManuallyDrop instead of forget inside collectionsTrevor Spiteri-9/+7
This commit changes some usage of mem::forget into mem::ManuallyDrop in some Vec, VecDeque, BTreeMap and Box methods. Before the commit, the generated IR for some of the methods was longer, and even after optimization, some unwinding artifacts were still present.
2020-04-01Add missing allocation guard in `RawVec::grow`Tim Diekmann-0/+1
2020-03-28Make fields in `MemoryBlock` publicTim Diekmann-4/+4
2020-03-26Remove alignment from `MemoryBlock`Tim Diekmann-23/+19
2020-03-26Fix safety section of `RawVec::into_box`Tim Diekmann-1/+2
2020-03-26Fix wording in `RawVec::from_raw_parts(_in)`Tim Diekmann-2/+2
2020-03-26Remove check for ZST in `RawVec::needs_to_grow`Tim Diekmann-2/+1
2020-03-26Refine docs for `RawVec::from_raw_parts(_in)`Tim Diekmann-4/+6
2020-03-26Remove the note on the internal capacity field in `RawVec`Tim Diekmann-3/+1
2020-03-26Fix assertion in `shrink` to use `capacity()` insteadTim Diekmann-1/+1
2020-03-26Fix comment in `RawVec::into_box()`Tim Diekmann-1/+1
2020-03-26Fix ZST handling for `RawVec`Tim Diekmann-6/+6
2020-03-26Fix issues from review and unsoundness of `RawVec::into_box`Tim Diekmann-114/+114
2020-03-26Overhaul of the `AllocRef` trait to match allocator-wg's latest consensTim Diekmann-347/+221
2020-03-08Allow ZSTs in `AllocRef`Tim Diekmann-20/+18
2020-03-03Remove `usable_size` APIsTim Diekmann-8/+13
2020-02-10Remove common usage pattern from `AllocRef`Tim Diekmann-6/+7
2020-01-27Rename `Alloc` to `AllocRef`Tim Diekmann-8/+8
2019-12-22Format the worldMark Rousskov-71/+55
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-1/+1
2019-12-18no need to bootstrapMark Mansi-8/+1
2019-12-18add fixmeMark Mansi-0/+1
2019-12-18fix importMark Mansi-1/+1
2019-12-18use usize::MAX instead of !0Mark Mansi-1/+1
2019-12-18remove a bit more hackeryMark Mansi-41/+8
2019-12-18Remove a const-if-hack in RawVecMark Mansi-8/+32
2019-09-16Const-stabilize `Vec::new`.Mazdak Farrokhzad-1/+26
2019-09-14Update src/liballoc/raw_vec.rsAlexander Regueiro-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-09-06A few cosmetic improvements to code & comments in liballoc and libcoreAlexander Regueiro-76/+74
2019-08-16Add the Layout of the failed allocation to TryReserveError::AllocErrorSimon Sapin-9/+11
… and add a separately-unstable field to force non-exhaustive matching (`#[non_exhaustive]` is no implemented yet on enum variants) so that we have the option to later expose the allocator’s error value. CC https://github.com/rust-lang/wg-allocators/issues/23
2019-08-16Rename CollectionAllocError to TryReserveErrorSimon Sapin-6/+6
2019-08-02liballoc: Unconfigure tests during normal buildVadim Petrochenkov-79/+3
Remove additional libcore-like restrictions from liballoc, turns out the testing works ok if the tests are a part of liballoc itself.
2019-07-25Auto merge of #60340 - mgeier:cap-vs-capacity, r=alexcrichtonbors-59/+60
Rename .cap() methods to .capacity() As mentioned in #60316, there are a few `.cap()` methods, which seem out-of-place because such methods are called `.capacity()` in the rest of the code. This PR renames them to `.capacity()` but leaves `RawVec::cap()` in there for backwards compatibility. I didn't try to mark the old version as "deprecated", because I guess this would cause too much noise.
2019-06-25Remove RawVec::cap()Matthias Geier-6/+0
As suggested in https://github.com/rust-lang/rust/pull/60340#issuecomment-493681032
2019-05-27avoid materializing unintialized Boxes in RawVecAleksey Kladov-4/+6
2019-04-27Rename .cap() methods to .capacity()Matthias Geier-59/+66
... but leave the old names in there for backwards compatibility.
2019-04-12Stabilize the `alloc` crate.Simon Sapin-2/+2
This implements RFC 2480: * https://github.com/rust-lang/rfcs/pull/2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes https://github.com/rust-lang/rust/issues/27783
2019-02-10libs: doc commentsAlexander Regueiro-2/+2
2019-02-03liballoc: revert nested imports style changes.Mazdak Farrokhzad-13/+9
2019-02-02liballoc: apply uniform_paths.Mazdak Farrokhzad-2/+2
2019-02-02liballoc: adjust abolute imports + more import fixes.Mazdak Farrokhzad-1/+1