Skip to content

Commit be0a4f2

Browse files
committed
Use explicit iteration instead of all() in process_obligation().
Amazingly enough, this is a 3.5% instruction count win on `keccak`.
1 parent 7f6e160 commit be0a4f2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/librustc/traits/fulfill.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,20 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
256256
&mut self,
257257
pending_obligation: &mut Self::Obligation,
258258
) -> ProcessResult<Self::Obligation, Self::Error> {
259-
// if we were stalled on some unresolved variables, first check
259+
// If we were stalled on some unresolved variables, first check
260260
// whether any of them have been resolved; if not, don't bother
261261
// doing more work yet
262262
if !pending_obligation.stalled_on.is_empty() {
263-
if pending_obligation.stalled_on.iter().all(|&ty| {
263+
let mut changed = false;
264+
for &ty in &pending_obligation.stalled_on {
264265
// Use the force-inlined variant of shallow_resolve() because this code is hot.
265266
let resolved = ShallowResolver::new(self.selcx.infcx()).inlined_shallow_resolve(ty);
266-
resolved == ty // nothing changed here
267-
}) {
267+
if resolved != ty {
268+
changed = true;
269+
break;
270+
}
271+
}
272+
if !changed {
268273
debug!("process_predicate: pending obligation {:?} still stalled on {:?}",
269274
self.selcx.infcx()
270275
.resolve_vars_if_possible(&pending_obligation.obligation),

0 commit comments

Comments
 (0)