about summary refs log tree commit diff
path: root/src/liballoc/raw_vec.rs
AgeCommit message (Collapse)AuthorLines
2015-10-31Fix excessive memory allocation in RawVec::reserveStepan Koltsov-3/+49
Before this patch `reserve` function allocated twice as requested amount elements (not twice as capacity). It leaded to unnecessary excessive memory usage in scenarios like this: ``` let mut v = Vec::new(); v.push(17); v.extend(0..10); println!("{}", v.capacity()); ``` `Vec` allocated 22 elements, while it could allocate just 11. `reserve` function must have a property of keeping `push` operation cost (which calls `reserve`) `O(1)`. To achieve this `reserve` must exponentialy grow its capacity when it does reallocation. There's better strategy to implement `reserve`: ``` let new_capacity = max(current_capacity * 2, requested_capacity); ``` This strategy still guarantees that capacity grows at `O(1)` with `reserve`, and fixes the issue with `extend`. Patch imlpements this strategy.
2015-10-30Typo fixSimon Sapin-1/+1
… I think.
2015-10-13Correct spelling in docsAndrew Paseltiner-5/+5
2015-10-11Run rustfmt on liballoc.Ahmed Charles-5/+13
2015-10-06Add RFC 1238's `unsafe_destructor_blind_to_params` (UGEH) where needed.Felix S. Klock II-0/+1
I needed it in `RawVec`, `Vec`, and `TypedArena` for `rustc` to bootstrap; but of course that alone was not sufficient for `make check`. Later I added `unsafe_destructor_blind_to_params` to collections, in particular `LinkedList` and `RawTable` (the backing representation for `HashMap` and `HashSet`), to get the regression tests exercising cyclic structure from PR #27185 building. ---- Note that the feature is `dropck_parametricity` (which is not the same as the attribute's name). We will almost certainly vary our strategy here in the future, so it makes some sense to have a not-as-ugly name for the feature gate. (The attribute name was deliberately selected to be ugly looking.)
2015-09-24Better function callsNick Cameron-4/+12
2015-09-24rustfmt liballocNick Cameron-18/+38
2015-08-15Reduce libcore/liballoc's dependence on pointer sizesDylan McKay-6/+4
2015-07-17Add RawVec to unify raw Vecish codeAlexis Beingessner-0/+453