We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e1e5c0c + 13fd74d commit 308418fCopy full SHA for 308418f
Sources/SwiftFormatCore/Rule.swift
@@ -27,9 +27,12 @@ fileprivate var nameCache = [ObjectIdentifier: String]()
27
extension Rule {
28
/// By default, the `ruleName` is just the name of the implementing rule class.
29
public static var ruleName: String {
30
- return nameCache[
31
- ObjectIdentifier(self),
32
- default: String("\(self)".split(separator: ".").last!)
33
- ]
+ let identifier = ObjectIdentifier(self)
+ if let cachedName = nameCache[identifier] {
+ return cachedName
+ }
34
+ let name = String("\(self)".split(separator: ".").last!)
35
+ nameCache[identifier] = name
36
+ return name
37
}
38
0 commit comments