skip eq_types and sub_types when the two types are equal

This commit is contained in:
Niko Matsakis 2018-06-01 13:17:45 -04:00
parent 956e2f8348
commit 73a09f35b1

View file

@ -759,6 +759,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
sup: Ty<'tcx>,
locations: Locations,
) -> UnitResult<'tcx> {
// Micro-optimization.
if sub == sup {
return Ok(());
}
self.fully_perform_op(
locations,
|| format!("sub_types({:?} <: {:?})", sub, sup),
@ -772,6 +777,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
#[inline(never)]
fn eq_types(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, locations: Locations) -> UnitResult<'tcx> {
// Micro-optimization.
if a == b {
return Ok(());
}
self.fully_perform_op(
locations,
|| format!("eq_types({:?} = {:?})", a, b),