Skip to content

Commit 493e9c4

Browse files
committed
Revert "Temporarily revert optimization"
This reverts commit e2426be.
1 parent e2426be commit 493e9c4

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

stdlib/public/core/Array.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,13 +1878,15 @@ extension Array {
18781878
let insertCount = newElements.count
18791879
let growth = insertCount - eraseCount
18801880

1881-
_reserveCapacityImpl(
1881+
let punchedHole = _reserveCapacityImplForReplaceSubrange(
18821882
minimumCapacity: self.count + growth,
1883-
growForAppend: true)
1883+
growForAppend: growth > 0,
1884+
rangeToNotCopy: subrange)
18841885
_buffer.replaceSubrange(
18851886
subrange,
18861887
with: insertCount,
1887-
elementsOf: newElements)
1888+
elementsOf: newElements,
1889+
holeAlreadyPunched: punchedHole)
18881890
_endMutation()
18891891
}
18901892
}

stdlib/public/core/ContiguousArray.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,13 +1398,15 @@ extension ContiguousArray {
13981398
let insertCount = newElements.count
13991399
let growth = insertCount - eraseCount
14001400

1401-
_reserveCapacityImpl(
1401+
let punchedHole = _reserveCapacityImplForReplaceSubrange(
14021402
minimumCapacity: self.count + growth,
1403-
growForAppend: true)
1403+
growForAppend: growth > 0,
1404+
rangeToNotCopy: subrange)
14041405
_buffer.replaceSubrange(
14051406
subrange,
14061407
with: insertCount,
1407-
elementsOf: newElements)
1408+
elementsOf: newElements,
1409+
holeAlreadyPunched: punchedHole)
14081410
_endMutation()
14091411
}
14101412
}

0 commit comments

Comments
 (0)