summary refs log tree commit diff
path: root/src/libcollectionstest
AgeCommit message (Collapse)AuthorLines
2015-10-24Add assertions to test_total_ord for strKevin Butler-5/+5
2015-10-24Remove unnecessary String allocations from str testsKevin Butler-50/+30
2015-10-20Auto merge of #27723 - mystor:vecdeque_drain_range, r=blussbors-4/+4
This is a WIP PR for my implementation of drain over the VecDeque data structure supporting ranges. It brings the VecDeque drain implementation in line with Vec's. Tests haven't been written for the new function yet.
2015-10-19Correct drain implementations in libcollectionstestMichael Layzell-4/+4
2015-10-08typos: fix a grabbag of typos all over the placeCristi Cobzarenco-1/+1
2015-09-28Minor code cleanup.Scott Olson-1/+1
2015-09-27Rollup merge of #28682 - apasel422:features, r=steveklabnikManish Goregaokar-5/+0
2015-09-26Remove unnecessary `#![feature]` attributesAndrew Paseltiner-5/+0
2015-09-25std: Update MatchIndices to return a subsliceAlex Crichton-2/+2
This commit updates the `MatchIndices` and `RMatchIndices` iterators to follow the same pattern as the `chars` and `char_indices` iterators. The `matches` iterator currently yield `&str` elements, so the `MatchIndices` iterator now yields the index of the match as well as the `&str` that matched (instead of start/end indexes). cc #27743
2015-09-20Miscellaneous cleanup for old issues.Lee Jeffery-9/+3
2015-09-18Avoid zero-sized leaf allocations in `BTreeMap`Andrew Paseltiner-0/+53
When both the key and value types were zero-sized, `BTreeMap` previously called `heap::allocate` with `size == 0` for leaf nodes, which is undefined behavior, and jemalloc would attempt to read invalid memory, crashing the process. This avoids undefined behavior by allocating enough space to store one edge in leaf nodes that would otherwise have `size == 0`. Although this uses extra memory, maps with zero-sized key types that have sensible implementations of the ordering traits can only contain a single key-value pair (and therefore only a single leaf node), and maps with key and value types that are both zero-sized have few uses, if any. Furthermore, this is a temporary fix that will likely be unnecessary once the `BTreeMap` implementation is rewritten to use parent pointers. Closes #28493.
2015-09-03std: Account for CRLF in {str, BufRead}::linesAlex Crichton-2/+2
This commit is an implementation of [RFC 1212][rfc] which tweaks the behavior of the `str::lines` and `BufRead::lines` iterators. Both iterators now account for `\r\n` sequences in addition to `\n`, allowing for less surprising behavior across platforms (especially in the `BufRead` case). Splitting *only* on the `\n` character can still be achieved with `split('\n')` in both cases. The `str::lines_any` function is also now deprecated as `str::lines` is a drop-in replacement for it. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1212-line-endings.md Closes #28032
2015-09-02Auto merge of #28148 - eefriedman:binary_heap, r=alexcrichtonbors-0/+1
2015-09-01Add missing stability markings to BinaryHeap.Eli Friedman-0/+1
2015-08-31Auto merge of #28101 - ijks:24214-str-bytes, r=alexcrichtonbors-0/+31
Specifically, `count`, `last`, and `nth` are implemented to use the methods of the underlying slice iterator. Partially closes #24214.
2015-08-30Add overrides to iterator methods for `str::Bytes`Daan Rijks-0/+31
Specifically, `count`, `last`, and `nth` are implemented to use the methods of the underlying slice iterator. Partially closes #24214.
2015-08-28implement RFC 1194Andrew Paseltiner-0/+50
2015-08-18Auto merge of #27474 - bluss:twoway-reverse, r=brsonbors-0/+20
StrSearcher: Implement the complete reverse case for the two way algorithm Fix quadratic behavior in StrSearcher in reverse search with periodic needles. This commit adds the missing pieces for the "short period" case in reverse search. The short case will show up when the needle is literally periodic, for example "abababab". Two way uses a "critical factorization" of the needle: x = u v. Searching matches v first, if mismatch at character k, skip k forward. Matching u, if mismatch, skip period(x) forward. To avoid O(mn) behavior after mismatch in u, memorize the already matched prefix. The short period case requires that |u| < period(x). For the reverse search we need to compute a different critical factorization x = u' v' where |v'| < period(x), because we are searching for the reversed needle. A short v' also benefits the algorithm in general. The reverse critical factorization is computed quickly by using the same maximal suffix algorithm, but terminating as soon as we have a location with local period equal to period(x). This adds extra fields crit_pos_back and memory_back for the reverse case. The new overhead for TwoWaySearcher::new is low, and additionally I think the "short period" case is uncommon in many applications of string search. The maximal_suffix methods were updated in documentation and the algorithms updated to not use !0 and wrapping add, variable left is now 1 larger, offset 1 smaller. Use periodicity when computing byteset: in the periodic case, just iterate over one period instead of the whole needle. Example before (rfind) after (twoway_rfind) benchmark shows the removal of quadratic behavior. needle: "ab" * 100, haystack: ("bb" + "ab" * 100) * 100 ``` test periodic::rfind ... bench: 1,926,595 ns/iter (+/- 11,390) = 10 MB/s test periodic::twoway_rfind ... bench: 51,740 ns/iter (+/- 66) = 386 MB/s ```
2015-08-14Auto merge of #27696 - bluss:into-boxed-str, r=alexcrichtonbors-4/+4
Rename String::into_boxed_slice -> into_boxed_str This is the name that was decided in rust-lang/rfcs#1152, and it's better if we say “boxed str” for `Box<str>`. The old name `String::into_boxed_slice` is deprecated.
2015-08-13Rename String::into_boxed_slice -> into_boxed_strUlrik Sverdrup-4/+4
This is the name that was decided in rust-lang/rfcs#1152, and it's better if we say “boxed str” for `Box<str>`. The old name `String::into_boxed_slice` is deprecated.
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-2790/+14
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-02StrSearcher: Add tests for rfind(&str)Ulrik Sverdrup-0/+20
Add tests for .rfind(&str), using the reverse searcher case for substring search.
2015-07-29implement Clone for Box<str>, closes #27323Alexis Beingessner-0/+8
This is a minor [breaking-change], as it changes what `boxed_str.to_owned()` does (previously it would deref to `&str` and call `to_owned` on that to get a `String`). However `Box<str>` is such an exceptionally rare type that this is not expected to be a serious concern. Also a `Box<str>` can be freely converted to a `String` to obtain the previous behaviour anyway.
2015-07-28Implement Clone for Box<[T]> where T: CloneJonathan Reem-0/+53
Closes #25097
2015-07-17Add RawVec to unify raw Vecish codeAlexis Beingessner-30/+0
2015-07-13Auto merge of #26241 - SimonSapin:derefmut-for-string, r=alexcrichtonbors-0/+14
See https://github.com/rust-lang/rfcs/issues/1157
2015-07-13Fix tests for changes in #26241.Simon Sapin-0/+1
2015-07-13Add str::split_at_mutSimon Sapin-0/+13
2015-07-12Auto merge of #26957 - wesleywiser:rename_connect_to_join, r=alexcrichtonbors-25/+25
Fixes #26900
2015-07-12Auto merge of #26966 - nagisa:tail-init, r=alexcrichtonbors-42/+20
Fixes #26906
2015-07-11Add String::into_boxed_slice and Box<str>::into_stringJonathan Reem-0/+16
Implements merged RFC 1152. Closes #26697.
2015-07-12Implement RFC 1058Simonas Kazlauskas-42/+20
2015-07-10Change some instances of .connect() to .join()Wesley Wiser-25/+25
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-4/+4
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-06-30Auto merge of #26327 - bluss:two-way, r=aturonbors-1/+9
Update substring search to use the Two Way algorithm To improve our substring search performance, revive the two way searcher and adapt it to the Pattern API. Fixes #25483, a performance bug: that particular case now completes faster in optimized rust than in ruby (but they share the same order of magnitude). Many thanks to @gereeter who helped me understand the reverse case better and wrote the comment explaining `next_back` in the code. I had quickcheck to fuzz test forward and reverse searching thoroughly. The two way searcher implements both forward and reverse search, but not double ended search. The forward and reverse parts of the two way searcher are completely independent. The two way searcher algorithm has very small, constant space overhead, requiring no dynamic allocation. Our implementation is relatively fast, especially due to the `byteset` addition to the algorithm, which speeds up many no-match cases. A bad case for the two way algorithm is: ``` let haystack = (0..10_000).map(|_| "dac").collect::<String>(); let needle = (0..100).map(|_| "bac").collect::<String>()); ``` For this particular case, two way is not much faster than the naive implementation it replaces.
2015-06-24Remove remaining use of `bit_vec_append_splitoff` feature gate.Johannes Oertel-1/+0
2015-06-21StrSearcher: Update substring search to use the Two Way algorithmUlrik Sverdrup-1/+9
To improve our substring search performance, revive the two way searcher and adapt it to the Pattern API. Fixes #25483, a performance bug: that particular case now completes faster in optimized rust than in ruby (but they share the same order of magnitude). Much thanks to @gereeter who helped me understand the reverse case better and wrote the comment explaining `next_back` in the code. I had quickcheck to fuzz test forward and reverse searching thoroughly. The two way searcher implements both forward and reverse search, but not double ended search. The forward and reverse parts of the two way searcher are completely independent. The two way searcher algorithm has very small, constant space overhead, requiring no dynamic allocation. Our implementation is relatively fast, especially due to the `byteset` addition to the algorithm, which speeds up many no-match cases. A bad case for the two way algorithm is: ``` let haystack = (0..10_000).map(|_| "dac").collect::<String>(); let needle = (0..100).map(|_| "bac").collect::<String>()); ``` For this particular case, two way is not much faster than the naive implementation it replaces.
2015-06-17More test fixes and fallout of stability changesAlex Crichton-1/+1
2015-06-17Fallout in tests and docs from feature renamingsAlex Crichton-12/+44
2015-06-11Auto merge of #26190 - Veedrac:no-iter, r=alexcrichtonbors-6/+6
Pull request for #26188.
2015-06-11Auto merge of #26122 - bluss:borrow-box, r=alexcrichtonbors-0/+29
Implement Borrow<T> and BorrowMut<T> for Box<T: ?Sized>
2015-06-11Auto merge of #25839 - bluss:str-split-at-impl, r=alexcrichtonbors-0/+20
Implement RFC rust-lang/rfcs#1123 Add str method str::split_at(mid: usize) -> (&str, &str). Also a minor cleanup in the collections::str module. Remove redundant slicing of self.
2015-06-10Removed many pointless calls to *iter() and iter_mut()Joshua Landau-6/+6
2015-06-10Add str::split_atUlrik Sverdrup-0/+20
Implement RFC rust-lang/rfcs#1123 Add str method str::split_at(mid: usize) -> (&str, &str).
2015-06-09Auto merge of #26039 - SimonSapin:case-mapping, r=alexcrichtonbors-0/+39
* Add “complex” mappings to `char::to_lowercase` and `char::to_uppercase`, making them yield sometimes more than on `char`: #25800. `str::to_lowercase` and `str::to_uppercase` are affected as well. * Add `char::to_titlecase`, since it’s the same algorithm (just different data). However this does **not** add `str::to_titlecase`, as that would require UAX#29 Unicode Text Segmentation which we decided not to include in of `std`: https://github.com/rust-lang/rfcs/pull/1054 I made `char::to_titlecase` immediately `#[stable]`, since it’s so similar to `char::to_uppercase` that’s already stable. Let me know if it should be `#[unstable]` for a while. * Add a special case for upper-case Sigma in word-final position in `str::to_lowercase`: #26035. This is the only language-independent conditional mapping currently in `SpecialCasing.txt`. * Stabilize `str::to_lowercase` and `str::to_uppercase`. The `&self -> String` on `str` signature seems straightforward enough, and the only relevant issue I’ve found is #24536 about naming. But `char` already has stable methods with the same name, and deprecating them for a rename doesn’t seem worth it. r? @alexcrichton
2015-06-09Implement Borrow<T> and BorrowMut<T> for Box<T: ?Sized>Ulrik Sverdrup-0/+29
2015-06-09Move collectionstest::char into coretest::charSimon Sapin-43/+0
2015-06-08Auto merge of #26077 - SimonSapin:patch-6, r=alexcrichtonbors-64/+64
With the latter is provided by the `From` conversion trait, the former is now completely redundant. Their code is identical. Let’s deprecate now and plan to remove in the next cycle. (It’s `#[unstable]`.) r? @alexcrichton CC @nagisa
2015-06-08Address a review comment and fix a bootstrapping issueSimon Sapin-1/+27
2015-06-08Replace usage of String::from_str with String:fromSimon Sapin-64/+64