File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,10 @@ extension _StringGuts {
233
233
234
234
// TODO(cleanup): Add append on guts taking range, use that
235
235
var result = String ( )
236
- result. reserveCapacity ( self . count &- ( upperOffset &- lowerOffset) )
236
+ // FIXME: It should be okay to get rid of excess capacity
237
+ // here. rdar://problem/45635432
238
+ result. reserveCapacity (
239
+ nativeCapacity ?? ( count &- ( upperOffset &- lowerOffset) ) )
237
240
result. append ( contentsOf: String ( self ) [ ..< lower] )
238
241
result. append ( contentsOf: String ( self ) [ upper... ] )
239
242
self = result. _guts
@@ -258,6 +261,11 @@ extension _StringGuts {
258
261
}
259
262
260
263
var result = String ( )
264
+ // FIXME: It should be okay to get rid of excess capacity
265
+ // here. rdar://problem/45635432
266
+ if let capacity = self . nativeCapacity {
267
+ result. reserveCapacity ( capacity)
268
+ }
261
269
let selfStr = String ( self )
262
270
result. append ( contentsOf: selfStr [ ..< bounds. lowerBound] )
263
271
result. append ( contentsOf: newElements)
You can’t perform that action at this time.
0 commit comments