Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7ba34c7

Browse files
committed
Auto merge of #142317 - compiler-errors:perf-fold, r=lcnr
Don't fold in Instantiate when there's nothing to fold Maybe this helps idk r? lcnr
2 parents b63223c + d032119 commit 7ba34c7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎compiler/rustc_type_ir/src/binder.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,17 @@ impl<I: Interner, T: TypeFoldable<I>> ty::EarlyBinder<I, T> {
622622
where
623623
A: SliceLike<Item = I::GenericArg>,
624624
{
625+
// Nothing to fold, so let's avoid visiting things and possibly re-hashing/equating
626+
// them when interning. Perf testing found this to be a modest improvement.
627+
// See: <https://github.com/rust-lang/rust/pull/142317>
628+
if args.is_empty() {
629+
assert!(
630+
!self.value.has_param(),
631+
"{:?} has parameters, but no args were provided in instantiate",
632+
self.value,
633+
);
634+
return self.value;
635+
}
625636
let mut folder = ArgFolder { cx, args: args.as_slice(), binders_passed: 0 };
626637
self.value.fold_with(&mut folder)
627638
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /