Skip to content

[stdlib] Uninline float description #20038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions stdlib/public/core/FloatingPointTypes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,19 @@ public struct ${Self} {

extension ${Self} : CustomStringConvertible {
/// A textual representation of the value.
@inlinable
public var description: String {
if isFinite {
return _float${bits}ToString(self, debug: false)
} else if isNaN {
if isNaN {
return "nan"
} else if sign == .minus {
return "-inf"
} else {
return "inf"
return _float${bits}ToString(self, debug: false)
}
}
}

extension ${Self} : CustomDebugStringConvertible {
/// A textual representation of the value, suitable for debugging.
public var debugDescription: String {
if isFinite || isNaN {
return _float${bits}ToString(self, debug: true)
} else if sign == .minus {
return "-inf"
} else {
return "inf"
}
return _float${bits}ToString(self, debug: true)
}
}

Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/core/Runtime.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,13 @@ internal struct _Buffer72 {
#if !os(Windows) && (arch(i386) || arch(x86_64))
% end

@usableFromInline // FIXME(sil-serialize-all)
@_silgen_name("swift_float${bits}ToString")
internal func _float${bits}ToStringImpl(
_ buffer: UnsafeMutablePointer<UTF8.CodeUnit>,
_ bufferLength: UInt, _ value: Float${bits},
_ debug: Bool
) -> UInt

@inlinable // FIXME(sil-serialize-all)
internal func _float${bits}ToString(
_ value: Float${bits}, debug: Bool
) -> String {
Expand Down
6 changes: 6 additions & 0 deletions test/api-digester/Outputs/stability-stdlib-abi.swift.expected
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Constructor _DropFirstSequence.init(_iterator:limit:dropped:) has been removed
Constructor _PrefixSequence.init(_iterator:maxLength:taken:) has been removed
Func _DropFirstSequence.next() has been removed
Func _PrefixSequence.next() has been removed
Func _float32ToString(_:debug:) has been removed
Func _float32ToStringImpl(_:_:_:_:) has been removed
Func _float64ToString(_:debug:) has been removed
Func _float64ToStringImpl(_:_:_:_:) has been removed
Func _float80ToString(_:debug:) has been removed
Func _float80ToStringImpl(_:_:_:_:) has been removed
Var _DropFirstSequence._dropped has been removed
Var _DropFirstSequence._iterator has been removed
Var _PrefixSequence._iterator has been removed
Expand Down