mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user