@@ -108,7 +108,7 @@ public struct DefaultStringInterpolation: StringInterpolationProtocol {
108
108
public mutating func appendInterpolation< T> ( _ value: T )
109
109
where T: TextOutputStreamable , T: CustomStringConvertible
110
110
{
111
- value. write ( to: & _storage )
111
+ value. write ( to: & self )
112
112
}
113
113
114
114
/// Interpolates the given value's textual representation into the
@@ -130,7 +130,7 @@ public struct DefaultStringInterpolation: StringInterpolationProtocol {
130
130
public mutating func appendInterpolation< T> ( _ value: T )
131
131
where T: TextOutputStreamable
132
132
{
133
- value. write ( to: & _storage )
133
+ value. write ( to: & self )
134
134
}
135
135
136
136
/// Interpolates the given value's textual representation into the
@@ -154,7 +154,7 @@ public struct DefaultStringInterpolation: StringInterpolationProtocol {
154
154
public mutating func appendInterpolation< T> ( _ value: T )
155
155
where T: CustomStringConvertible
156
156
{
157
- _storage += value. description
157
+ value. description. write ( to : & self )
158
158
}
159
159
160
160
/// Interpolates the given value's textual representation into the
@@ -176,7 +176,7 @@ public struct DefaultStringInterpolation: StringInterpolationProtocol {
176
176
/// // Prints "If one cookie costs 2 dollars, 3 cookies cost 6 dollars."
177
177
@inlinable
178
178
public mutating func appendInterpolation< T> ( _ value: T ) {
179
- _print_unlocked ( value, & _storage )
179
+ _print_unlocked ( value, & self )
180
180
}
181
181
182
182
/// Creates a string from this instance, consuming the instance in the
@@ -194,6 +194,20 @@ extension DefaultStringInterpolation: CustomStringConvertible {
194
194
}
195
195
}
196
196
197
+ extension DefaultStringInterpolation : TextOutputStream {
198
+ @inlinable
199
+ public mutating func write( _ string: String ) {
200
+ // Most interpolations will not append to an empty string, so we bypass the
201
+ // empty-singleton check.
202
+ _storage. _guts. _appendSlow ( string. _guts)
203
+ }
204
+
205
+ @inlinable
206
+ public mutating func _writeASCII( _ buffer: UnsafeBufferPointer < UInt8 > ) {
207
+ _storage. _guts. append ( _UnmanagedString ( buffer) )
208
+ }
209
+ }
210
+
197
211
// While not strictly necessary, declaring these is faster than using the
198
212
// default implementation.
199
213
extension String {
0 commit comments