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 {
453453 @inlinable
454454 public mutating func append< S: Sequence > ( contentsOf newElements: __owned S)
455455 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+ }
461467 }
462468 }
463469
You can’t perform that action at this time.
0 commit comments