Rename UnsafePointer assign/initialize and eliminate Backward variants. (#3585)

Also fixes the comments to clarify that source and self memory
must be disjoint.
This commit is contained in:
Andrew Trick
2016-07-18 15:15:47 -07:00
committed by GitHub
parent 18fb99ad71
commit 0230efc614
13 changed files with 163 additions and 203 deletions

View File

@@ -384,9 +384,8 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
_sanityCheck(bounds.upperBound <= count)
let initializedCount = bounds.upperBound - bounds.lowerBound
target.initializeFrom(
firstElementAddress + bounds.lowerBound,
count: initializedCount)
target.initialize(
from: firstElementAddress + bounds.lowerBound, count: initializedCount)
_fixLifetime(owner)
return target + initializedCount
}
@@ -507,18 +506,18 @@ public func += <Element, C : Collection>(
if _fastPath(newCount <= lhs.capacity) {
lhs.count = newCount
(lhs.firstElementAddress + oldCount).initializeFrom(rhs)
(lhs.firstElementAddress + oldCount).initialize(from: rhs)
}
else {
var newLHS = _ContiguousArrayBuffer<Element>(
uninitializedCount: newCount,
minimumCapacity: _growArrayCapacity(lhs.capacity))
newLHS.firstElementAddress.moveInitializeFrom(
lhs.firstElementAddress, count: oldCount)
newLHS.firstElementAddress.moveInitialize(
from: lhs.firstElementAddress, count: oldCount)
lhs.count = 0
swap(&lhs, &newLHS)
(lhs.firstElementAddress + oldCount).initializeFrom(rhs)
(lhs.firstElementAddress + oldCount).initialize(from: rhs)
}
}
@@ -653,9 +652,8 @@ internal struct _UnsafePartiallyInitializedContiguousArrayBuffer<Element> {
uninitializedCount: newCapacity, minimumCapacity: 0)
p = newResult.firstElementAddress + result.capacity
remainingCapacity = newResult.capacity - result.capacity
newResult.firstElementAddress.moveInitializeFrom(
result.firstElementAddress,
count: result.capacity)
newResult.firstElementAddress.moveInitialize(
from: result.firstElementAddress, count: result.capacity)
result.count = 0
swap(&result, &newResult)
}