rust/src
Josh Stone 13724fafdc Add more custom folding to core::iter adaptors
Many of the iterator adaptors will perform faster folds if they forward
to their inner iterator's folds, especially for inner types like `Chain`
which are optimized too.  The following types are newly specialized:

| Type        | `fold` | `rfold` |
| ----------- | ------ | ------- |
| `Enumerate` | ✓      | ✓       |
| `Filter`    | ✓      | ✓       |
| `FilterMap` | ✓      | ✓       |
| `FlatMap`   | exists | ✓       |
| `Fuse`      | ✓      | ✓       |
| `Inspect`   | ✓      | ✓       |
| `Peekable`  | ✓      | N/A¹    |
| `Skip`      | ✓      | N/A²    |
| `SkipWhile` | ✓      | N/A¹    |

¹ not a `DoubleEndedIterator`

² `Skip::next_back` doesn't pull skipped items at all, but this couldn't
be avoided if `Skip::rfold` were to call its inner iterator's `rfold`.

Benchmarks
----------

In the following results, plain `_sum` computes the sum of a million
integers -- note that `sum()` is implemented with `fold()`.  The
`_ref_sum` variants do the same on a `by_ref()` iterator, which is
limited to calling `next()` one by one, without specialized `fold`.

The `chain` variants perform the same tests on two iterators chained
together, to show a greater benefit of forwarding `fold` internally.

    test iter::bench_enumerate_chain_ref_sum  ... bench:   2,216,264 ns/iter (+/- 29,228)
    test iter::bench_enumerate_chain_sum      ... bench:     922,380 ns/iter (+/- 2,676)
    test iter::bench_enumerate_ref_sum        ... bench:     476,094 ns/iter (+/- 7,110)
    test iter::bench_enumerate_sum            ... bench:     476,438 ns/iter (+/- 3,334)

    test iter::bench_filter_chain_ref_sum     ... bench:   2,266,095 ns/iter (+/- 6,051)
    test iter::bench_filter_chain_sum         ... bench:     745,594 ns/iter (+/- 2,013)
    test iter::bench_filter_ref_sum           ... bench:     889,696 ns/iter (+/- 1,188)
    test iter::bench_filter_sum               ... bench:     667,325 ns/iter (+/- 1,894)

    test iter::bench_filter_map_chain_ref_sum ... bench:   2,259,195 ns/iter (+/- 353,440)
    test iter::bench_filter_map_chain_sum     ... bench:   1,223,280 ns/iter (+/- 1,972)
    test iter::bench_filter_map_ref_sum       ... bench:     611,607 ns/iter (+/- 2,507)
    test iter::bench_filter_map_sum           ... bench:     611,610 ns/iter (+/- 472)

    test iter::bench_fuse_chain_ref_sum       ... bench:   2,246,106 ns/iter (+/- 22,395)
    test iter::bench_fuse_chain_sum           ... bench:     634,887 ns/iter (+/- 1,341)
    test iter::bench_fuse_ref_sum             ... bench:     444,816 ns/iter (+/- 1,748)
    test iter::bench_fuse_sum                 ... bench:     316,954 ns/iter (+/- 2,616)

    test iter::bench_inspect_chain_ref_sum    ... bench:   2,245,431 ns/iter (+/- 21,371)
    test iter::bench_inspect_chain_sum        ... bench:     631,645 ns/iter (+/- 4,928)
    test iter::bench_inspect_ref_sum          ... bench:     317,437 ns/iter (+/- 702)
    test iter::bench_inspect_sum              ... bench:     315,942 ns/iter (+/- 4,320)

    test iter::bench_peekable_chain_ref_sum   ... bench:   2,243,585 ns/iter (+/- 12,186)
    test iter::bench_peekable_chain_sum       ... bench:     634,848 ns/iter (+/- 1,712)
    test iter::bench_peekable_ref_sum         ... bench:     444,808 ns/iter (+/- 480)
    test iter::bench_peekable_sum             ... bench:     317,133 ns/iter (+/- 3,309)

    test iter::bench_skip_chain_ref_sum       ... bench:   1,778,734 ns/iter (+/- 2,198)
    test iter::bench_skip_chain_sum           ... bench:     761,850 ns/iter (+/- 1,645)
    test iter::bench_skip_ref_sum             ... bench:     478,207 ns/iter (+/- 119,252)
    test iter::bench_skip_sum                 ... bench:     315,614 ns/iter (+/- 3,054)

    test iter::bench_skip_while_chain_ref_sum ... bench:   2,486,370 ns/iter (+/- 4,845)
    test iter::bench_skip_while_chain_sum     ... bench:     633,915 ns/iter (+/- 5,892)
    test iter::bench_skip_while_ref_sum       ... bench:     666,926 ns/iter (+/- 804)
    test iter::bench_skip_while_sum           ... bench:     444,405 ns/iter (+/- 571)
2017-09-25 20:53:08 -07:00
..
bootstrap Fix fuchsia toolchain prebuild setup 2017-09-24 21:32:27 -07:00
build_helper Add a file to trivially disable tool building or testing 2017-09-17 21:41:45 +02:00
ci Fix fuchsia toolchain prebuild setup 2017-09-24 21:32:27 -07:00
doc Auto merge of #44620 - zackmdavis:rfc_1940_housekeeping, r=nikomatsakis 2017-09-19 13:06:31 +00:00
etc Rollup merge of #44351 - lu-zero:master, r=nikomatsakis 2017-09-06 18:28:03 -06:00
grammar
jemalloc@1f5a28755e Update jemalloc to 4.5.0 2017-08-16 22:06:05 +02:00
liballoc Add missing links for Arc 2017-09-22 15:45:37 +02:00
liballoc_jemalloc Add a file to trivially disable tool building or testing 2017-09-17 21:41:45 +02:00
liballoc_system Autodetect the type of allocator crate used 2017-09-10 19:59:42 +02:00
libarena stabilized needs_drop (fixes #41890) 2017-09-16 23:41:04 +02:00
libbacktrace Fix missing line numbers on i686. 2017-09-05 08:41:43 +08:00
libcollections *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libcompiler_builtins@ef4951582f Update submodules. 2017-09-24 13:53:10 -07:00
libcore Add more custom folding to core::iter adaptors 2017-09-25 20:53:08 -07:00
libfmt_macros *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libgetopts *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libgraphviz *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
liblibc@44e4018e1a bump liblibc to 0.2.31 2017-09-24 13:53:11 -07:00
libpanic_abort *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libpanic_unwind Add missing dependency for Windows 2017-08-27 19:02:24 +09:00
libproc_macro rustc: Forbid interpolated tokens in the HIR 2017-09-18 17:20:12 -07:00
libprofiler_builtins update gcc crate 2017-09-02 21:51:18 +02:00
librand *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
librustc Auto merge of #44646 - petrochenkov:scompress, r=michaelwoerister 2017-09-25 09:01:53 +00:00
librustc_allocator Make fields of Span private 2017-08-30 01:38:54 +03:00
librustc_apfloat Remove rustc_bitflags; use the bitflags crate 2017-09-17 14:19:24 -04:00
librustc_asan Bump master to 1.21.0 2017-07-25 07:03:19 -07:00
librustc_back rework the README.md for rustc and add other readmes 2017-09-19 09:00:59 -04:00
librustc_borrowck Only consider yields coming after the expressions when computing generator interiors 2017-09-20 16:36:24 +03:00
librustc_const_eval incr.comp.: Already hash HIR bodies during metadata export so they don't have to be hashed in downstream crates. 2017-09-18 11:26:11 +02:00
librustc_const_math change #![feature(const_fn)] to specific gates 2017-09-16 15:53:02 +00:00
librustc_cratesio_shim Remove rustc_bitflags; use the bitflags crate 2017-09-17 14:19:24 -04:00
librustc_data_structures incr.comp.: Add some comments. 2017-09-20 11:34:28 +02:00
librustc_driver Auto merge of #44646 - petrochenkov:scompress, r=michaelwoerister 2017-09-25 09:01:53 +00:00
librustc_errors Fix mispositioned error indicators 2017-09-07 10:26:27 +02:00
librustc_incremental incr.comp.: Remove out-dated unit test and unnecessary assertion. 2017-09-23 19:49:05 +02:00
librustc_lint add comparison operators to must-use lint (under fn_must_use feature) 2017-09-22 15:45:47 -07:00
librustc_llvm Remove rustc_bitflags; use the bitflags crate 2017-09-17 14:19:24 -04:00
librustc_lsan Bump master to 1.21.0 2017-07-25 07:03:19 -07:00
librustc_metadata incr.comp.: Remove support for loading metadata fingerprints. 2017-09-23 19:47:37 +02:00
librustc_mir Auto merge of #44700 - arielb1:mir-effectck, r=nikomatsakis 2017-09-25 00:52:15 +00:00
librustc_msan Bump master to 1.21.0 2017-07-25 07:03:19 -07:00
librustc_passes Implement underscore lifetimes 2017-09-20 23:45:05 -07:00
librustc_platform_intrinsics Rollup merge of #44351 - lu-zero:master, r=nikomatsakis 2017-09-06 18:28:03 -06:00
librustc_plugin *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
librustc_privacy Use recorded types in rustc_privacy 2017-09-23 00:50:46 +03:00
librustc_resolve Auto merge of #44215 - oli-obk:import_sugg, r=nrc 2017-09-21 20:12:22 +00:00
librustc_save_analysis Use NodeId/HirId instead of DefId for local variables. 2017-09-08 22:00:59 +03:00
librustc_trans incr.comp.: Serialize and deserialize new DepGraph 2017-09-23 19:47:28 +02:00
librustc_trans_utils change #![feature(const_fn)] to specific gates 2017-09-16 15:53:02 +00:00
librustc_tsan Move unused-extern-crate to late pass 2017-08-27 19:02:24 +09:00
librustc_typeck Auto merge of #44700 - arielb1:mir-effectck, r=nikomatsakis 2017-09-25 00:52:15 +00:00
librustdoc Auto merge of #44758 - arielb1:a-small-path, r=eddyb 2017-09-24 19:48:11 +00:00
libserialize *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libstd LP_CLONE_FDIO_ROOT is now LP_CLONE_FDIO_NAMESPACE 2017-09-24 14:31:50 -07:00
libstd_unicode [libstd_unicode] Expose UnicodeVersion type 2017-09-18 20:39:17 -07:00
libsyntax Rollup merge of #44103 - zackmdavis:cmp_op_must_use, r=arielb1 2017-09-24 14:01:49 +02:00
libsyntax_ext only set non-ADT derive error once per attribute, not per trait 2017-09-21 21:20:23 -07:00
libsyntax_pos Compress "small" spans to 32 bits and intern "large" spans 2017-09-23 00:34:13 +03:00
libterm *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libtest Platform gate libc in libtest 2017-08-27 19:02:24 +09:00
libunwind *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
llvm@d9e7d2696e Fix LLVM assertion when a weak symbol is defined in global_asm. 2017-07-18 16:52:00 +03:00
rt
rtstartup
rustc Trim and document libc shim 2017-09-21 22:25:02 -04:00
rustllvm Add 'native' to -C target-cpu=help 2017-09-15 00:32:59 -05:00
test Auto merge of #44700 - arielb1:mir-effectck, r=nikomatsakis 2017-09-25 00:52:15 +00:00
tools TODO --> FIXME 2017-09-24 13:53:10 -07:00
Cargo.lock Use recorded types in rustc_privacy 2017-09-23 00:50:46 +03:00
Cargo.toml Use double quotes to appease some TOML parsers 2017-09-17 13:14:37 -04:00
stage0.txt Bump to 1.22.0 2017-08-31 06:58:58 -07:00