[stdlib] Remove an unnecessary level of Optional. NFC.

This commit is contained in:
Jordan Rose
2016-03-31 15:21:14 -07:00
parent b911fda8ea
commit b0334cbcb4

View File

@@ -651,9 +651,8 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
@inline(never)
internal mutating func _copyToNewBuffer(oldCount: Int) {
let newCount = oldCount + 1
var newBuffer = Optional(
_forceCreateUniqueMutableBuffer(
&_buffer, countForNewBuffer: oldCount, minNewCapacity: newCount))
var newBuffer = _forceCreateUniqueMutableBuffer(
&_buffer, countForNewBuffer: oldCount, minNewCapacity: newCount)
_arrayOutOfPlaceUpdate(
&_buffer, &newBuffer, oldCount, 0, _IgnorePointer())
}
@@ -952,9 +951,8 @@ internal func _arrayOutOfPlaceReplace<
) {
let growth = insertCount - bounds.count
let newCount = source.count + growth
var newBuffer = Optional(
_forceCreateUniqueMutableBuffer(
&source, newCount: newCount, requiredCapacity: newCount))
var newBuffer = _forceCreateUniqueMutableBuffer(
&source, newCount: newCount, requiredCapacity: newCount)
_arrayOutOfPlaceUpdate(
&source, &newBuffer,
@@ -1128,7 +1126,7 @@ internal func _arrayOutOfPlaceUpdate<
_Buffer.Index == Int
>(
_ source: inout _Buffer,
_ dest: inout _ContiguousArrayBuffer<_Buffer.Element>?,
_ dest: inout _ContiguousArrayBuffer<_Buffer.Element>,
_ headCount: Int, // Count of initial source elements to copy/move
_ newCount: Int, // Number of new elements to insert
_ initializeNewElements: Initializer
@@ -1137,12 +1135,12 @@ internal func _arrayOutOfPlaceUpdate<
_sanityCheck(newCount >= 0)
// Count of trailing source elements to copy/move
let tailCount = dest!.count - headCount - newCount
let tailCount = dest.count - headCount - newCount
_sanityCheck(headCount + tailCount <= source.count)
let sourceCount = source.count
let oldCount = sourceCount - headCount - tailCount
let destStart = dest!.firstElementAddress
let destStart = dest.firstElementAddress
let newStart = destStart + headCount
let newEnd = newStart + newCount
@@ -1188,7 +1186,7 @@ internal func _arrayOutOfPlaceUpdate<
let tailEnd = source.endIndex
source._copyContents(subRange: tailStart..<tailEnd, initializing: newEnd)
}
source = _Buffer(dest!, shiftedToStartIndex: source.startIndex)
source = _Buffer(dest, shiftedToStartIndex: source.startIndex)
}
internal struct _InitializePointer<T> : _PointerFunction {
@@ -1224,9 +1222,8 @@ internal func _outlinedMakeUniqueBuffer<
return
}
var newBuffer = Optional(
_forceCreateUniqueMutableBuffer(
&buffer, newCount: bufferCount, requiredCapacity: bufferCount))
var newBuffer = _forceCreateUniqueMutableBuffer(
&buffer, newCount: bufferCount, requiredCapacity: bufferCount)
_arrayOutOfPlaceUpdate(&buffer, &newBuffer, bufferCount, 0, _IgnorePointer())
}
@@ -1245,9 +1242,8 @@ internal func _arrayReserve<
return
}
var newBuffer = Optional(
_forceCreateUniqueMutableBuffer(
&buffer, newCount: count, requiredCapacity: requiredCapacity))
var newBuffer = _forceCreateUniqueMutableBuffer(
&buffer, newCount: count, requiredCapacity: requiredCapacity)
_arrayOutOfPlaceUpdate(&buffer, &newBuffer, count, 0, _IgnorePointer())
}