Skip to content

Commit c423212

Browse files
committed
[stdlib] Fast-path ad-hoc printing of Strings
1 parent c4c5b71 commit c423212

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stdlib/public/core/OutputStream.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ internal func _adHocPrint_unlocked<T, TargetStream : TextOutputStream>(
380380
internal func _print_unlocked<T, TargetStream : TextOutputStream>(
381381
_ value: T, _ target: inout TargetStream
382382
) {
383+
if let string = value as? String {
384+
let mirror = Mirror(reflecting: string)
385+
_adHocPrint_unlocked(string, mirror, &target, isDebugPrint: false)
386+
return
387+
}
383388
// Optional has no representation suitable for display; therefore,
384389
// values of optional type should be printed as a debug
385390
// string. Check for Optional first, before checking protocol

0 commit comments

Comments
 (0)