mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user