Merge pull request #2338 from marcelofabri/empty_parentheses_with_trailing_closure-swift4.2

Improve empty_parentheses_with_trailing_closure performance on Swift 4.2
This commit is contained in:
Marcelo Fabri
2018-08-05 00:32:17 -07:00
committed by GitHub
@@ -70,6 +70,12 @@ public struct EmptyParenthesesWithTrailingClosureRule: ASTRule, CorrectableRule,
return []
}
// avoid the more expensive regex match if there's no trailing closure in the substructure
if SwiftVersion.current >= .fourDotTwo,
dictionary.substructure.last?.kind.flatMap(SwiftExpressionKind.init(rawValue:)) != .closure {
return []
}
let rangeStart = nameOffset + nameLength
let rangeLength = (offset + length) - (nameOffset + nameLength)
let regex = EmptyParenthesesWithTrailingClosureRule.emptyParenthesesRegex