[Swift] Replace all uses of NSStringFromClass.

Bridging from NSString to String in Swift 5 is a transcoding operation, so
it is expensive.  Use String(describing:) instead of NSStringFromClass
to avoid this cost.
This commit is contained in:
Ewan Mellor 2019-08-28 14:07:25 -07:00
parent 10d182cf66
commit a701f2b099
No known key found for this signature in database
GPG Key ID: 7CE1C6BC9EC8645D
2 changed files with 11 additions and 11 deletions

View File

@ -668,7 +668,7 @@ public class PredictionContext: Hashable, CustomStringConvertible {
}
public func toString<T>(_ recog: Recognizer<T>) -> String {
return NSStringFromClass(PredictionContext.self)
return String(describing: PredictionContext.self)
// return toString(recog, ParserRuleContext.EMPTY);
}

View File

@ -54,16 +54,16 @@ public class Transition {
public static let serializationTypes: Dictionary<String, Int> = [
NSStringFromClass(EpsilonTransition.self): EPSILON,
NSStringFromClass(RangeTransition.self): RANGE,
NSStringFromClass(RuleTransition.self): RULE,
NSStringFromClass(PredicateTransition.self): PREDICATE,
NSStringFromClass(AtomTransition.self): ATOM,
NSStringFromClass(ActionTransition.self): ACTION,
NSStringFromClass(SetTransition.self): SET,
NSStringFromClass(NotSetTransition.self): NOT_SET,
NSStringFromClass(WildcardTransition.self): WILDCARD,
NSStringFromClass(PrecedencePredicateTransition.self): PRECEDENCE,
String(describing: EpsilonTransition.self): EPSILON,
String(describing: RangeTransition.self): RANGE,
String(describing: RuleTransition.self): RULE,
String(describing: PredicateTransition.self): PREDICATE,
String(describing: AtomTransition.self): ATOM,
String(describing: ActionTransition.self): ACTION,
String(describing: SetTransition.self): SET,
String(describing: NotSetTransition.self): NOT_SET,
String(describing: WildcardTransition.self): WILDCARD,
String(describing: PrecedencePredicateTransition.self): PRECEDENCE,
]