Skip to content

Commit bfef1ee

Browse files
author
Yurii Samsoniuk
authored
Also update workspace content
1 parent e149dac commit bfef1ee

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Merge Sort/MergeSort.playground/Contents.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ func merge<T: Comparable>(leftPile: [T], rightPile: [T]) -> [T] {
1212
var leftIndex = 0
1313
var rightIndex = 0
1414
var orderedPile = [T]()
15+
if orderedPile.capacity < leftPile.count + rightPile.count {
16+
orderedPile.reserveCapacity(leftPile.count + rightPile.count)
17+
}
1518

1619
while leftIndex < leftPile.count && rightIndex < rightPile.count {
1720
if leftPile[leftIndex] < rightPile[rightIndex] {

0 commit comments

Comments
 (0)