Skip to content

Commit 875297b

Browse files
committed
Remove old C implementation
1 parent 8e40ac8 commit 875297b

File tree

7 files changed

+24
-3259
lines changed

7 files changed

+24
-3259
lines changed

Runtimes/Core/runtime/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ add_library(swiftRuntime OBJECT
5252
RefCount.cpp
5353
ReflectionMirror.cpp
5454
RuntimeInvocationsTracking.cpp
55-
SwiftDtoa.cpp
5655
SwiftTLSContext.cpp
5756
ThreadingError.cpp
5857
Tracing.cpp

include/swift/Runtime/SwiftDtoa.h

Lines changed: 0 additions & 302 deletions
This file was deleted.

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ extension ${Self}: CustomStringConvertible {
106106
if isNaN {
107107
return "nan"
108108
} else {
109-
var (buffer, length) = _float${bits}ToString(self, debug: false)
110-
return unsafe buffer.withBytes { (bufferPtr) in
111-
unsafe String._fromASCII(
112-
UnsafeBufferPointer(start: bufferPtr, count: length))
113-
}
109+
return debugDescription
114110
}
115111
}
116112
}
@@ -122,31 +118,16 @@ extension ${Self}: CustomDebugStringConvertible {
122118
/// This property has the same value as the `description` property, except
123119
/// that NaN values are printed in an extended format.
124120
public var debugDescription: String {
125-
var (buffer, length) = _float${bits}ToString(self, debug: true)
126-
return unsafe buffer.withBytes { (bufferPtr) in
127-
unsafe String._fromASCII(
128-
UnsafeBufferPointer(start: bufferPtr, count: length))
129-
}
130-
}
131-
}
132-
133-
${Availability(bits)}
134-
extension ${Self} {
135-
// Temporary `debugDescription2` that uses the new Swift implementation.
136-
// `debugDescription` above is still using the old C implementation
137-
// for now so we can compare performance and results between the two.
138-
@available(macOS 15, *)
139-
public var debugDescription2: String {
140-
if #available(macOS 9999, *) {
141-
var buffer = InlineArray<64, UTF8.CodeUnit>(repeating: 0)
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-
return unsafe String._fromASCII(textBuff)
121+
if #available(SwiftStdlib 6.2, *) {
122+
var buffer = InlineArray<64, UTF8.CodeUnit>(repeating: 0)
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)
150131
} else {
151132
fatalError()
152133
}
@@ -155,11 +136,19 @@ extension ${Self} {
155136

156137
${Availability(bits)}
157138
extension ${Self}: TextOutputStreamable {
158-
public func write<Target>(to target: inout Target) where Target: TextOutputStream {
159-
var (buffer, length) = _float${bits}ToString(self, debug: true)
160-
unsafe buffer.withBytes { (bufferPtr) in
161-
let bufPtr = unsafe UnsafeBufferPointer(start: bufferPtr, count: length)
162-
unsafe target._writeASCII(bufPtr)
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: 0)
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()
163152
}
164153
}
165154
}

0 commit comments

Comments
 (0)