Skip to content

Commit 7388732

Browse files
committed
Remove availability check for internal float-to-string functions
1 parent 7b55ac3 commit 7388732

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -118,38 +118,30 @@ extension ${Self}: CustomDebugStringConvertible {
118118
/// This property has the same value as the `description` property, except
119119
/// that NaN values are printed in an extended format.
120120
public var debugDescription: String {
121-
if #available(SwiftStdlib 6.2, *) {
122-
var buffer = InlineArray<64, UTF8.CodeUnit>(repeating: 0x30)
123-
var span = buffer.mutableSpan
124-
let textRange = _Float${bits}ToASCII(value: self, buffer: &span)
125-
let textStart = unsafe span._start().assumingMemoryBound(to: UTF8.CodeUnit.self) + textRange.lowerBound
126-
let textLength = textRange.upperBound - textRange.lowerBound
127-
128-
let textBuff = unsafe UnsafeBufferPointer<UTF8.CodeUnit>(_uncheckedStart: textStart,
129-
count: textLength)
130-
return unsafe String._fromASCII(textBuff)
131-
} else {
132-
fatalError()
133-
}
121+
var buffer = _InlineArray<64, UTF8.CodeUnit>(repeating: 0x30)
122+
var span = buffer.mutableSpan
123+
let textRange = _Float${bits}ToASCII(value: self, buffer: &span)
124+
let textStart = unsafe span._start().assumingMemoryBound(to: UTF8.CodeUnit.self) + textRange.lowerBound
125+
let textLength = textRange.upperBound - textRange.lowerBound
126+
127+
let textBuff = unsafe UnsafeBufferPointer<UTF8.CodeUnit>(_uncheckedStart: textStart,
128+
count: textLength)
129+
return unsafe String._fromASCII(textBuff)
134130
}
135131
}
136132

137133
${Availability(bits)}
138134
extension ${Self}: TextOutputStreamable {
139-
public func write<Target>(to target: inout Target) where Target: TextOutputStream {
140-
if #available(SwiftStdlib 6.2, *) {
141-
var buffer = InlineArray<64, UTF8.CodeUnit>(repeating: 0x30)
142-
var span = buffer.mutableSpan
143-
let textRange = _Float${bits}ToASCII(value: self, buffer: &span)
144-
let textStart = unsafe span._start().assumingMemoryBound(to: UTF8.CodeUnit.self) + textRange.lowerBound
145-
let textLength = textRange.upperBound - textRange.lowerBound
146-
147-
let textBuff = unsafe UnsafeBufferPointer<UTF8.CodeUnit>(_uncheckedStart: textStart,
148-
count: textLength)
149-
unsafe target._writeASCII(textBuff)
150-
} else {
151-
fatalError()
152-
}
135+
public func write<Target>(to target: inout Target) where Target: TextOutputStream {
136+
var buffer = _InlineArray<64, UTF8.CodeUnit>(repeating: 0x30)
137+
var span = buffer.mutableSpan
138+
let textRange = _Float${bits}ToASCII(value: self, buffer: &span)
139+
let textStart = unsafe span._start().assumingMemoryBound(to: UTF8.CodeUnit.self) + textRange.lowerBound
140+
let textLength = textRange.upperBound - textRange.lowerBound
141+
142+
let textBuff = unsafe UnsafeBufferPointer<UTF8.CodeUnit>(_uncheckedStart: textStart,
143+
count: textLength)
144+
unsafe target._writeASCII(textBuff)
153145
}
154146
}
155147

0 commit comments

Comments
 (0)