File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -453,11 +453,17 @@ extension RangeReplaceableCollection {
453
453
@inlinable
454
454
public mutating func append< S: Sequence > ( contentsOf newElements: __owned S)
455
455
where S. Element == Element {
456
-
457
- let approximateCapacity = self . count + newElements. underestimatedCount
458
- self . reserveCapacity ( approximateCapacity)
459
- for element in newElements {
460
- append ( element)
456
+
457
+ let done : Void ? = newElements. withContiguousStorageIfAvailable {
458
+ replaceSubrange ( endIndex..< endIndex, with: $0)
459
+ }
460
+
461
+ if done == nil {
462
+ let approximateCapacity = self . count + newElements. underestimatedCount
463
+ self . reserveCapacity ( approximateCapacity)
464
+ for element in newElements {
465
+ append ( element)
466
+ }
461
467
}
462
468
}
463
469
You can’t perform that action at this time.
0 commit comments