Skip to content

Commit

Permalink
Avoid erase_regions_ty queries if there are no regions to erase
Browse files Browse the repository at this point in the history
It's overall faster to perform this extra check than to perform the
query, even if the result is already in the query cache.
  • Loading branch information
dotdash committed Jan 16, 2019
1 parent ceb2512 commit dae6e8f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/librustc/ty/erase_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn erase_regions<T>(self, value: &T) -> T
where T : TypeFoldable<'tcx>
{
// If there's nothing to erase avoid performing the query at all
if !value.has_erasable_regions() {
return value.clone();
}

let value1 = value.fold_with(&mut RegionEraserVisitor { tcx: self });
debug!("erase_regions({:?}) = {:?}", value, value1);
value1
Expand Down

0 comments on commit dae6e8f

Please sign in to comment.