about summary refs log tree commit diff
path: root/src/liballoc
AgeCommit message (Collapse)AuthorLines
2018-03-28Rollup merge of #49243 - murarth:stabilize-retain, r=BurntSushikennytm-3/+1
Stabilize method `String::retain` Closes #43874
2018-03-28Clarify "length" wording in `Vec::with_capacity`.Corey Farwell-3/+4
2018-03-28Add run-pass test for repeat-generic-slice featureGuillaume Gomez-0/+19
2018-03-28Add repeat method on sliceGuillaume Gomez-53/+72
2018-03-27Rollup merge of #49401 - alercah:format, r=cramertjkennytm-7/+8
Add missing '?' to format grammar.
2018-03-27Rollup merge of #49381 - withoutboats:str_unicode, r=SimonSapinkennytm-0/+42
Add is_whitespace and is_alphanumeric to str. The other methods from `UnicodeStr` are already stable inherent methods on str, but these have not been included. r? @SimonSapin
2018-03-27Rollup merge of #48639 - varkor:sort_by_key-cached, r=blusskennytm-13/+111
Add slice::sort_by_cached_key as a memoised sort_by_key At present, `slice::sort_by_key` calls its key function twice for each comparison that is made. When the key function is expensive (which can often be the case when `sort_by_key` is chosen over `sort_by`), this can lead to very suboptimal behaviour. To address this, I've introduced a new slice method, `sort_by_cached_key`, which has identical semantic behaviour to `sort_by_key`, except that it guarantees the key function will only be called once per element. Where there are `n` elements and the key function is `O(m)`: - `slice::sort_by_cached_key` time complexity is `O(m n log m n)`, compared to `slice::sort_by_key`'s `O(m n + n log n)`. - `slice::sort_by_cached_key` space complexity remains at `O(n + m)`. (Technically, it now reserves a slice of size `n`, whereas before it reserved a slice of size `n/2`.) `slice::sort_unstable_by_key` has not been given an analogue, as it is important that unstable sorts are in-place, which is not a property that is guaranteed here. However, this also means that `slice::sort_unstable_by_key` is likely to be slower than `slice::sort_by_cached_key` when the key function does not have negligible complexity. We might want to explore this trade-off further in the future. Benchmarks (for a vector of 100 `i32`s): ``` # Lexicographic: `|x| x.to_string()` test bench_sort_by_key ... bench: 112,638 ns/iter (+/- 19,563) test bench_sort_by_cached_key ... bench: 15,038 ns/iter (+/- 4,814) # Identity: `|x| *x` test bench_sort_by_key ... bench: 1,346 ns/iter (+/- 238) test bench_sort_by_cached_key ... bench: 1,839 ns/iter (+/- 765) # Power: `|x| x.pow(31)` test bench_sort_by_key ... bench: 3,624 ns/iter (+/- 738) test bench_sort_by_cached_key ... bench: 1,997 ns/iter (+/- 311) # Abs: `|x| x.abs()` test bench_sort_by_key ... bench: 1,546 ns/iter (+/- 174) test bench_sort_by_cached_key ... bench: 1,668 ns/iter (+/- 790) ``` (So it seems functions that are single operations do perform slightly worse with this method, but for pretty much any more complex key, you're better off with this optimisation.) I've definitely found myself using expensive keys in the past and wishing this optimisation was made (e.g. for https://github.com/rust-lang/rust/pull/47415). This feels like both desirable and expected behaviour, at the small cost of slightly more stack allocation and minute degradation in performance for extremely trivial keys. Resolves #34447.
2018-03-26Add missing '?' to format grammar.Alexis Hunt-7/+8
2018-03-27Implement `shrink_to` method on collectionsDiggory Blake-2/+113
2018-03-26Remove mentions of unstable sort_by_cached key from stable documentationvarkor-8/+0
2018-03-26Auto merge of #49101 - mark-i-m:stabilize_i128, r=nagisabors-2/+2
Stabilize 128-bit integers :tada: cc #35118 EDIT: This should be merged only after the following have been merged: - [x] https://github.com/rust-lang-nursery/compiler-builtins/pull/236 - [x] https://github.com/rust-lang/book/pull/1230
2018-03-26Stabilize i128_typeMark Mansi-2/+2
2018-03-26Add is_whitespace and is_alphanumeric to str.boats-0/+42
The other methods from `UnicodeStr` are already stable inherent methods on str, but these have not been included.
2018-03-25Implement get_key_value for HashMap, BTreeMapDiggory Blake-0/+27
2018-03-25Rollup merge of #49194 - Zoxc:unsafe-generator, r=cramertjkennytm-1/+1
Make resuming generators unsafe instead of the creation of immovable generators cc @withoutboats Fixes #47787
2018-03-25Rollup merge of #49121 - varkor:stabilise-from_utf8_error_as_bytes, r=blusskennytm-2/+1
Stabilise FromUtf8Error::as_bytes Closes #40895.
2018-03-23Rollup merge of #48265 - SimonSapin:nonzero, r=KodrAusAlex Crichton-16/+14
Add 12 num::NonZero* types for primitive integers, deprecate core::nonzero RFC: https://github.com/rust-lang/rfcs/pull/2307 Tracking issue: ~~https://github.com/rust-lang/rust/issues/27730~~ https://github.com/rust-lang/rust/issues/49137 Fixes https://github.com/rust-lang/rust/issues/27730
2018-03-22Rollup merge of #49117 - nivkner:fixme_fixup3, r=estebankkennytm-1/+1
address some FIXME whose associated issues were marked as closed part of #44366
2018-03-21Stabilize method `String::retain`Murarth-3/+1
2018-03-21Make resuming generators unsafe instead of the creation of immovable ↵John Kåre Alsaker-1/+1
generators. Fixes #47787
2018-03-20Auto merge of #49190 - kennytm:rollup, r=kennytmbors-1/+1
Rollup of 17 pull requests - Successful merges: #46518, #48810, #48834, #48902, #49004, #49092, #49096, #49099, #49104, #49125, #49139, #49152, #49157, #49161, #49166, #49176, #49184 - Failed merges:
2018-03-20Auto merge of #48516 - petrochenkov:stabsl, r=nikomatsakisbors-1/+0
Stabilize slice patterns without `..` And merge `feature(advanced_slice_patterns)` into `feature(slice_patterns)`. The detailed description can be found in https://github.com/rust-lang/rust/issues/48836. Slice patterns were unstable for long time since before 1.0 due to many bugs in the implementation, now this stabilization is possible primarily due to work of @arielb1 who [wrote the new MIR-based implementation of slice patterns](https://github.com/rust-lang/rust/pull/32202) and @mikhail-m1 who [fixed one remaining class of codegen issues](https://github.com/rust-lang/rust/pull/47926). Reference PR https://github.com/rust-lang-nursery/reference/pull/259 cc https://github.com/rust-lang/rust/issues/23121 fixes #48836
2018-03-20Stabilize slice patterns without `..`Vadim Petrochenkov-1/+0
Merge `feature(advanced_slice_patterns)` into `feature(slice_patterns)`
2018-03-19Auto merge of #49058 - withoutboats:pin, r=cramertjbors-2/+100
Pin, Unpin, PinBox Implementing rust-lang/rfcs#2349 (do not merge until RFC is merged) @bors r? @cramertj
2018-03-19Docs: fix incorrect copy-paste for new `X?` in formatting stringsSimon Sapin-1/+1
2018-03-19Auto merge of #48978 - SimonSapin:debug-hex, r=KodrAusbors-0/+2
Add hexadecimal formatting of integers with fmt::Debug This can be used for integers within a larger types which implements Debug (possibly through derive) but not fmt::UpperHex or fmt::LowerHex. ```rust assert!(format!("{:02x?}", b"Foo\0") == "[46, 6f, 6f, 00]"); assert!(format!("{:02X?}", b"Foo\0") == "[46, 6F, 6F, 00]"); ``` RFC: https://github.com/rust-lang/rfcs/pull/2226 The new formatting string syntax (`x?` and `X?`) is insta-stable in this PR because I don’t know how to change a built-in proc macro’s behavior based of a feature gate. I can look into adding that, but I also strongly suspect that keeping this feature unstable for a time period would not be useful as possibly no-one would use it during that time. This PR does not add the new (public) `fmt::Formatter` proposed in the API because: * There was some skepticism on response to this part of the RFC * It is not possible to implement as-is without larger changes to `fmt`, because `Formatter` at the moment has no easy way to tell apart for example `Octal` from `Binary`: it only has a function pointer for the relevant `fmt()` method. If some integer-like type outside of `std` want to implement this behavior, another RFC will likely need to propose a different public API for `Formatter`.
2018-03-19Add stability test for sort_by_cached_keyvarkor-3/+8
2018-03-18Update tracking issue.boats-12/+12
2018-03-18Add lexicographic sorting benchmarkvarkor-0/+16
2018-03-18Check that the size optimisation is not redundantvarkor-5/+10
2018-03-18Clarify time complexityvarkor-3/+3
2018-03-17Use NonNull<_> instead of NonZero<*const _> in btree internalsSimon Sapin-16/+14
2018-03-17Stabilise FromUtf8Error::as_bytesvarkor-2/+1
Closes #40895.
2018-03-17Improve and fix documentation for sort_by_cached_keyvarkor-8/+12
2018-03-17update FIXME(#5244) to point to RFC 1109 (Non-Copy array creation ergonomics)Niv Kaminer-1/+1
2018-03-17Fix use of unstable feature in testvarkor-2/+4
2018-03-16Add sort_by_cached_key methodvarkor-14/+56
2018-03-16Index enumeration by minimally sized typevarkor-12/+25
2018-03-16Cull the quadraticvarkor-0/+1
2018-03-16Update documentationvarkor-10/+11
2018-03-16Add a test for sort_by_keyvarkor-0/+5
2018-03-16Clarify behaviour of sort_unstable_by_key with respect to sort_by_keyvarkor-4/+11
2018-03-16Update documentation for sort_by_keyvarkor-7/+4
2018-03-16Compute each key only one during slice::sort_by_keyvarkor-2/+10
2018-03-16Remove deprecated unstable alloc::heap::EMPTY constantSimon Sapin-8/+0
2018-03-16Auto merge of #49051 - kennytm:rollup, r=kennytmbors-18/+2
Rollup of 17 pull requests - Successful merges: #48706, #48875, #48892, #48922, #48957, #48959, #48961, #48965, #49007, #49024, #49042, #49050, #48853, #48990, #49037, #49049, #48972 - Failed merges:
2018-03-15Pin and PinBox are fundamental.boats-0/+1
2018-03-15CoerceUnsized for PinBoxboats-0/+3
2018-03-15Add liballoc APIs.boats-2/+96
2018-03-15setting ABORTING_MALLOC for asmjs backendsnf-18/+2