Skip to content

Commit

Permalink
Use explicit iteration instead of all() in process_obligation().
Browse files Browse the repository at this point in the history
Amazingly enough, this is a 3.5% instruction count win on `keccak`.
  • Loading branch information
nnethercote committed Sep 17, 2019
1 parent 7f6e160 commit be0a4f2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/librustc/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,20 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
&mut self,
pending_obligation: &mut Self::Obligation,
) -> ProcessResult<Self::Obligation, Self::Error> {
// if we were stalled on some unresolved variables, first check
// If we were stalled on some unresolved variables, first check
// whether any of them have been resolved; if not, don't bother
// doing more work yet
if !pending_obligation.stalled_on.is_empty() {
if pending_obligation.stalled_on.iter().all(|&ty| {
let mut changed = false;
for &ty in &pending_obligation.stalled_on {
// Use the force-inlined variant of shallow_resolve() because this code is hot.
let resolved = ShallowResolver::new(self.selcx.infcx()).inlined_shallow_resolve(ty);
resolved == ty // nothing changed here
}) {
if resolved != ty {
changed = true;
break;
}
}
if !changed {
debug!("process_predicate: pending obligation {:?} still stalled on {:?}",
self.selcx.infcx()
.resolve_vars_if_possible(&pending_obligation.obligation),
Expand Down

0 comments on commit be0a4f2

Please sign in to comment.