File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -1878,13 +1878,15 @@ extension Array {
1878
1878
let insertCount = newElements. count
1879
1879
let growth = insertCount - eraseCount
1880
1880
1881
- _reserveCapacityImpl (
1881
+ let punchedHole = _reserveCapacityImplForReplaceSubrange (
1882
1882
minimumCapacity: self . count + growth,
1883
- growForAppend: true )
1883
+ growForAppend: growth > 0 ,
1884
+ rangeToNotCopy: subrange)
1884
1885
_buffer. replaceSubrange (
1885
1886
subrange,
1886
1887
with: insertCount,
1887
- elementsOf: newElements)
1888
+ elementsOf: newElements,
1889
+ holeAlreadyPunched: punchedHole)
1888
1890
_endMutation ( )
1889
1891
}
1890
1892
}
Original file line number Diff line number Diff line change @@ -1398,13 +1398,15 @@ extension ContiguousArray {
1398
1398
let insertCount = newElements. count
1399
1399
let growth = insertCount - eraseCount
1400
1400
1401
- _reserveCapacityImpl (
1401
+ let punchedHole = _reserveCapacityImplForReplaceSubrange (
1402
1402
minimumCapacity: self . count + growth,
1403
- growForAppend: true )
1403
+ growForAppend: growth > 0 ,
1404
+ rangeToNotCopy: subrange)
1404
1405
_buffer. replaceSubrange (
1405
1406
subrange,
1406
1407
with: insertCount,
1407
- elementsOf: newElements)
1408
+ elementsOf: newElements,
1409
+ holeAlreadyPunched: punchedHole)
1408
1410
_endMutation ( )
1409
1411
}
1410
1412
}
You can’t perform that action at this time.
0 commit comments