]> git.lizzy.rs Git - rust.git/commit
Avoid useless Vec clones in pending_obligations().
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 19 Apr 2018 05:13:20 +0000 (15:13 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Thu, 7 Jun 2018 23:00:17 +0000 (09:00 +1000)
commitb0440d359b0dab992e8f01d63523799a72c81285
treed0012b134f27abb24bef1f2ab1323e189012fd9d
parentbe5f17ccff09569c2dd22df9330364a92fec2295
Avoid useless Vec clones in pending_obligations().

The only instance of `ObligationForest` in use has an obligation type of
`PendingPredicateObligation`, which contains a `PredicateObligation` and a
`Vec<Ty>`.

`FulfillmentContext::pending_obligations()` calls
`ObligationForest::pending_obligations()`, which clones all the
`PendingPredicateObligation`s. But the `Vec<Ty>` field of those cloned
obligations is never touched.

This patch changes `ObligationForest::pending_obligations()` to
`map_pending_obligations` -- which gives callers control about which part
of the obligation to clone -- and takes advantage of the change to avoid
cloning the `Vec<Ty>`. The change speeds up runs of a few rustc-perf
benchmarks, the best by 1%.
src/librustc/traits/engine.rs
src/librustc/traits/fulfill.rs
src/librustc_data_structures/obligation_forest/mod.rs
src/librustc_typeck/check/closure.rs