Skip to content

Commit 210d115

Browse files
committed
EscapeUtils: speed up hasRelevantType
The run time of `Value.hasTrivialNonPointerType` is not negligible, because it does a cache lookup of type lowerings. Only do this check if it's really needed.
1 parent ed21728 commit 210d115

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/EscapeUtils.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,14 +819,14 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
819819
}
820820

821821
private func hasRelevantType(_ value: Value, at path: SmallProjectionPath) -> Bool {
822-
if !value.hasTrivialNonPointerType {
823-
return true
824-
}
825822
if visitor.followTrivialTypes &&
826823
// When part of a class field only need to follow non-trivial types
827824
!path.hasClassProjection {
828825
return true
829826
}
827+
if !value.hasTrivialNonPointerType {
828+
return true
829+
}
830830
return false
831831
}
832832

0 commit comments

Comments
 (0)