File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -536,6 +536,13 @@ open class NSNumber : NSValue {
536
536
}
537
537
}
538
538
539
+ private static let _numberFormatterForNilLocale : CFNumberFormatter = {
540
+ let formatter : CFNumberFormatter
541
+ formatter = CFNumberFormatterCreate ( nil , CFLocaleCopyCurrent ( ) , kCFNumberFormatterNoStyle)
542
+ CFNumberFormatterSetProperty ( formatter, kCFNumberFormatterMaxFractionDigits, 15 . _bridgeToObjectiveC ( ) )
543
+ return formatter
544
+ } ( )
545
+
539
546
open func description( withLocale locale: Locale ? ) -> String {
540
547
// CFNumberFormatterCreateStringWithNumber() doesnt like SInt128Type as
541
548
// it loses the type when looking it up and treats it as an SInt64Type
@@ -548,9 +555,7 @@ open class NSNumber : NSValue {
548
555
let aLocale = locale
549
556
let formatter : CFNumberFormatter
550
557
if ( aLocale == nil ) {
551
- formatter = CFNumberFormatterCreate ( nil , CFLocaleCopyCurrent ( ) , kCFNumberFormatterNoStyle)
552
- CFNumberFormatterSetProperty ( formatter, kCFNumberFormatterMaxFractionDigits, 15 . _bridgeToObjectiveC ( ) )
553
-
558
+ formatter = NSNumber . _numberFormatterForNilLocale
554
559
} else {
555
560
formatter = CFNumberFormatterCreate ( nil , aLocale? . _cfObject, kCFNumberFormatterDecimalStyle)
556
561
}
You can’t perform that action at this time.
0 commit comments