| Age | Commit message (Collapse) | Author | Lines |
|
Separate out of bounds errors from character boundary errors, and print
more details for character boundary errors.
Example:
&"abcαβγ"[..4]
thread 'str::test_slice_fail_boundary_1' panicked at 'byte index 4 is not
a char boundary; it is inside `α` (bytes 3..5) of `abcαβγ`'
|
|
|
|
Fixes #26554.
|
|
Because we handle artifically-constructed references to it in live code which
is a totally broken thing to do.
|
|
|
|
Implement RFC 1679
cc #35729
r? @alexcrichton
|
|
Add rustbuild command `bench`
Add command bench to rustbuild, so that `./x.py bench <path>` can compile and run benchmarks.
`./x.py bench --stage 1 src/libcollections` and `./x.py bench --stage 1 src/libstd` should both compile well. Just `./x.py bench` runs all benchmarks for the libstd crates.
Fixes #37897
|
|
|
|
Rollup of 7 pull requests
- Successful merges: #37962, #37963, #37967, #37978, #37985, #38001, #38010
- Failed merges:
|
|
Fix two small issues in iterator docs
- `collect()` is a regular method, not an adaptor (does not return an Iterator). I just randomly picked `filter` as a third common adaptor to mention instead.
- Fix example in `Map`'s docs so that it uses the DoubleEndedIterator implementation
|
|
Use "radices" instead of "radicum"
The correct plural of "radix" is "radices" or "radixes", not "radicum".
|
|
|
|
Forward ExactSizeIterator::len and is_empty for important iterator adaptors
Forward ExactSizeIterator::len and is_empty for important iterator adaptors
Because some iterators will provide improved version of len and/or is_empty,
adaptors should forward to those implementations if possible.
|
|
Introduce a helper method .search_while() that generalizes internal
iteration (Iterator's all, find, position, fold and so on).
The compiler does not unroll loops with conditional exits; we can do
this manually instead to improve the performance of for example
Iterator::find and Iterator::position when used on the slice iterators.
The unrolling is patterned on libstdc++'s implementation of std::find_if.
|
|
|
|
Use an extension trait for the slice iterator's pointer manipulations.
|
|
Implement better .is_empty() for slice and vec iterators
These iterators can use a pointer comparison instead of computing the length.
|
|
|
|
Make the example use DoubleEndedIterator for map, like it said it would.
|
|
|
|
These iterators can use a pointer comparison instead of computing the length.
|
|
|
|
|
|
|
|
Make Peekable remember peeking a None
Peekable should remember if a None has been seen in the `.peek()` method.
It ensures that `.peek(); .peek();` or `.peek(); .next();` only advances the
underlying iterator at most once. This does not by itself make the iterator
fused.
Thanks to @s3bk for the code in `fn peek()` itself.
Fixes #37784
|
|
Simplify the conditional used for ensuring that the whole word loop is
only used if there are at least two whole words left to read.
This makes the function slightly smaller and simpler, a 0-5% reduction
in runtime for various test cases.
|
|
Improve .chars().count()
Use a simpler loop to count the `char` of a string: count the
number of non-continuation bytes. Use `count += <conditional>` which the
compiler understands well and can apply loop optimizations to.
benchmark descriptions and results for two configurations:
- ascii: ascii text
- cy: cyrillic text
- jp: japanese text
- words ascii: counting each split_whitespace item from the ascii text
- words jp: counting each split_whitespace item from the jp text
```
x86-64 rustc -Copt-level=3
name orig_ ns/iter cmov_ ns/iter diff ns/iter diff %
count_ascii 1,453 (1755 MB/s) 1,398 (1824 MB/s) -55 -3.79%
count_cy 5,990 (856 MB/s) 2,545 (2016 MB/s) -3,445 -57.51%
count_jp 3,075 (1169 MB/s) 1,772 (2029 MB/s) -1,303 -42.37%
count_words_ascii 4,157 (521 MB/s) 1,797 (1205 MB/s) -2,360 -56.77%
count_words_jp 3,337 (1071 MB/s) 1,772 (2018 MB/s) -1,565 -46.90%
x86-64 rustc -Ctarget-feature=+avx -Copt-level=3
name orig_ ns/iter cmov_ ns/iter diff ns/iter diff %
count_ascii 1,444 (1766 MB/s) 763 (3343 MB/s) -681 -47.16%
count_cy 5,871 (874 MB/s) 1,527 (3360 MB/s) -4,344 -73.99%
count_jp 2,874 (1251 MB/s) 1,073 (3351 MB/s) -1,801 -62.67%
count_words_ascii 4,131 (524 MB/s) 1,871 (1157 MB/s) -2,260 -54.71%
count_words_jp 3,253 (1099 MB/s) 1,331 (2686 MB/s) -1,922 -59.08%
```
I briefly explored a more involved blocked algorithm (looking at 8 or more bytes at a time),
but the code in this PR was always winning `count_words_ascii` in particular (counting
many small strings); this solution is an improvement without tradeoffs.
|
|
Optimise Chars::last()
The default implementation of last() goes through the entire iterator
but that's not needed here.
|
|
The default implementation of last() goes through the entire iterator
but that's not needed here.
|
|
Use a simpler loop to count the `char` of a string: count the
number of non-continuation bytes. Use `count += <conditional>` which the
compiler understands well and can apply loop optimizations to.
|
|
The default implementation of last() goes through the entire iterator
but that's not needed here.
|
|
The problem occured due to lines like
```
3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;
4DB5;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;;
```
in `UnicodeData.txt`, which the script previously interpreted as two
characters, although it represents the whole range.
Fixes #34318.
|
|
Peekable must remember if a None has been seen in the `.peek()` method.
It ensures that `.peek(); .peek();` or `.peek(); .next();` only advances the
underlying iterator at most once. This does not by itself make the iterator
fused.
|
|
|
|
Fix invalid src url
Fixes #37684.
Thanks to @eddyb's help.
r? @eddyb
|
|
Mem urls
r? @steveklabnik
|
|
Add missing urls for marker's traits
r? @steveklabnik
|
|
Add missing urls for FusedIterator and TrustedLen traits
r? @steveklabnik
|
|
Add documentation to some of the unstable intrinsics
Part of #34338
|
|
|
|
|
|
|
|
|
|
Add missing urls and few local rewrites
r? @steveklabnik
|
|
Document convention for using both fmt::Write and io::Write
Using a trait's methods (like `Write::write_fmt` as used in `writeln!` and other macros) requires importing that trait directly (not just the module containing it). Both `fmt::Write` and `io::Write` provide compatible `Write::write_fmt` methods, and code can use `writeln!` and other macros on both an object implementing `fmt::Write` (such as a `String`) and an object implementing `io::Write` (such as `Stderr`). However, importing both `Write` traits produces an error due to the name conflict.
The convention I've seen renames both of them on import, to `FmtWrite` and `IoWrite` respectively. Document that convention in the Rust documentation for `write!` and `writeln!`, with examples.
|
|
Part of #34338
|
|
Part of #34338
|
|
Part of #34338
|
|
|
|
|