@@ -530,10 +530,10 @@ extension UnsafeMutableBufferPointer {
530530 buffer: UnsafeMutablePointer < Element > ,
531531 by areInIncreasingOrder: ( Element , Element ) throws -> Bool
532532 ) rethrows -> Bool {
533- unsafe _internalInvariant ( runs [ i - 1 ] . upperBound == runs [ i] . lowerBound)
534- let low = unsafe runs[ i - 1 ] . lowerBound
535- let middle = unsafe runs[ i] . lowerBound
536- let high = unsafe runs[ i] . upperBound
533+ _internalInvariant ( runs [ i - 1 ] . upperBound == runs [ i] . lowerBound)
534+ let low = runs [ i - 1 ] . lowerBound
535+ let middle = runs [ i] . lowerBound
536+ let high = runs [ i] . upperBound
537537
538538 try unsafe _merge(
539539 low: baseAddress! + low,
@@ -542,8 +542,8 @@ extension UnsafeMutableBufferPointer {
542542 buffer: buffer,
543543 by: areInIncreasingOrder)
544544
545- unsafe runs[ i - 1 ] = unsafe low..< high
546- unsafe runs. remove ( at: i)
545+ runs [ i - 1 ] = low..< high
546+ runs. remove ( at: i)
547547
548548 return true
549549 }
@@ -588,30 +588,30 @@ extension UnsafeMutableBufferPointer {
588588 // for the entirety of `runs`.
589589
590590 // The invariant is always in place for a single element.
591- while unsafe runs. count > 1 {
592- var lastIndex = unsafe runs. count - 1
591+ while runs. count > 1 {
592+ var lastIndex = runs. count - 1
593593
594594 // Check for the three invariant-breaking conditions, and break out of
595595 // the while loop if none are met.
596- if unsafe lastIndex >= 3 &&
596+ if lastIndex >= 3 &&
597597 ( runs [ lastIndex - 3 ] . count <=
598598 runs [ lastIndex - 2 ] . count + runs[ lastIndex - 1 ] . count)
599599 {
600600 // Second-to-last three runs do not follow W > X + Y.
601601 // Always merge Y with the smaller of X or Z.
602- if unsafe runs[ lastIndex - 2 ] . count < runs [ lastIndex] . count {
602+ if runs [ lastIndex - 2 ] . count < runs [ lastIndex] . count {
603603 lastIndex -= 1
604604 }
605- } else if unsafe lastIndex >= 2 &&
605+ } else if lastIndex >= 2 &&
606606 ( runs [ lastIndex - 2 ] . count <=
607607 runs [ lastIndex - 1 ] . count + runs[ lastIndex] . count)
608608 {
609609 // Last three runs do not follow X > Y + Z.
610610 // Always merge Y with the smaller of X or Z.
611- if unsafe runs[ lastIndex - 2 ] . count < runs [ lastIndex] . count {
611+ if runs [ lastIndex - 2 ] . count < runs [ lastIndex] . count {
612612 lastIndex -= 1
613613 }
614- } else if unsafe runs[ lastIndex - 1 ] . count <= runs [ lastIndex] . count {
614+ } else if runs [ lastIndex - 1 ] . count <= runs [ lastIndex] . count {
615615 // Last two runs do not follow Y > Z, so merge Y and Z.
616616 // This block is intentionally blank--the merge happens below.
617617 } else {
@@ -645,7 +645,7 @@ extension UnsafeMutableBufferPointer {
645645 buffer: UnsafeMutablePointer < Element > ,
646646 by areInIncreasingOrder: ( Element , Element ) throws -> Bool
647647 ) rethrows -> Bool {
648- while unsafe runs. count > 1 {
648+ while runs. count > 1 {
649649 try unsafe _mergeRuns(
650650 & runs, at: runs. count - 1 , buffer: buffer, by: areInIncreasingOrder)
651651 }
@@ -677,7 +677,7 @@ extension UnsafeMutableBufferPointer {
677677 // closure, since the buffer is guaranteed to be uninitialized at exit.
678678 _ = try unsafe Array< Element> ( _unsafeUninitializedCapacity: count / 2 ) {
679679 buffer, _ in
680- var runs : [ Range < Index > ] = unsafe [ ]
680+ var runs : [ Range < Index > ] = [ ]
681681
682682 var start = startIndex
683683 while start < endIndex {
@@ -690,24 +690,24 @@ extension UnsafeMutableBufferPointer {
690690
691691 // If the current run is shorter than the minimum length, use the
692692 // insertion sort to extend it.
693- if unsafe end < endIndex && end - start < minimumRunLength {
693+ if end < endIndex && end - start < minimumRunLength {
694694 let newEnd = Swift . min ( endIndex, start + minimumRunLength)
695695 try unsafe _insertionSort(
696696 within: start..< newEnd, sortedEnd: end, by: areInIncreasingOrder)
697- unsafe end = newEnd
697+ end = newEnd
698698 }
699699
700700 // Append this run and merge down as needed to maintain the `runs`
701701 // invariants.
702- unsafe runs. append ( start..< end)
702+ runs. append ( start..< end)
703703 try unsafe _mergeTopRuns(
704704 & runs, buffer: buffer. baseAddress!, by: areInIncreasingOrder)
705- start = unsafe end
705+ start = end
706706 }
707707
708708 try unsafe _finalizeRuns (
709709 & runs, buffer: buffer. baseAddress!, by: areInIncreasingOrder)
710- unsafe _internalInvariant ( runs. count == 1 , " Didn't complete final merge " )
710+ _internalInvariant ( runs. count == 1 , " Didn't complete final merge " )
711711 }
712712 }
713713}
0 commit comments