Skip to content

Commit

Permalink
Merge pull request #3374 from apple/SE-0114
Browse files Browse the repository at this point in the history
[stdlib] ManagedBuffer: rename Value => Header
  • Loading branch information
Dave Abrahams authored Jul 12, 2016
2 parents 5c2cda0 + 125823d commit e1e739f
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 113 deletions.
20 changes: 10 additions & 10 deletions stdlib/public/core/ContiguousArrayBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorage1 {

deinit {
__manager._elementPointer.deinitialize(
count: __manager._valuePointer.pointee.count)
__manager._valuePointer.deinitialize()
count: __manager._headerPointer.pointee.count)
__manager._headerPointer.deinitialize()
_fixLifetime(__manager)
}

Expand All @@ -114,7 +114,7 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorage1 {
_ body: @noescape (UnsafeBufferPointer<AnyObject>) throws -> Void
) rethrows {
if _isBridgedVerbatimToObjectiveC(Element.self) {
let count = __manager.value.count
let count = __manager.header.count
let elements = UnsafePointer<AnyObject>(__manager._elementPointer)
defer { _fixLifetime(__manager) }
try body(UnsafeBufferPointer(start: elements, count: count))
Expand All @@ -128,7 +128,7 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorage1 {
_sanityCheck(
!_isBridgedVerbatimToObjectiveC(Element.self),
"Verbatim bridging should be handled separately")
return __manager.value.count
return __manager.header.count
}

/// Bridge array elements and return a new buffer that owns them.
Expand All @@ -139,7 +139,7 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorage1 {
_sanityCheck(
!_isBridgedVerbatimToObjectiveC(Element.self),
"Verbatim bridging should be handled separately")
let count = __manager.value.count
let count = __manager.header.count
let result = _HeapBuffer<Int, AnyObject>(
_HeapBufferStorage<Int, AnyObject>.self, count, count)
let resultPtr = result.baseAddress
Expand Down Expand Up @@ -239,7 +239,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
let verbatim = false
#endif

__bufferPointer._valuePointer.initialize(with:
__bufferPointer._headerPointer.initialize(with:
_ArrayBody(
count: count,
capacity: capacity,
Expand Down Expand Up @@ -343,7 +343,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
/// The number of elements the buffer stores.
public var count: Int {
get {
return __bufferPointer.value.count
return __bufferPointer.header.count
}
nonmutating set {
_sanityCheck(newValue >= 0)
Expand All @@ -352,7 +352,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
newValue <= capacity,
"Can't grow an array buffer past its capacity")

__bufferPointer._valuePointer.pointee.count = newValue
__bufferPointer._headerPointer.pointee.count = newValue
}
}

Expand All @@ -361,14 +361,14 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
@inline(__always)
func _checkValidSubscript(_ index : Int) {
_precondition(
(index >= 0) && (index < __bufferPointer.value.count),
(index >= 0) && (index < __bufferPointer.header.count),
"Index out of range"
)
}

/// The number of elements the buffer can store without reallocation.
public var capacity: Int {
return __bufferPointer.value.capacity
return __bufferPointer.header.capacity
}

/// Copy the elements in `bounds` from this buffer into uninitialized
Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/core/HashedCollections.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -2505,10 +2505,10 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
// This API is unsafe and needs a `_fixLifetime` in the caller.
internal var _body: _HashedContainerStorageHeader {
unsafeAddress {
return UnsafePointer(buffer._valuePointer)
return UnsafePointer(buffer._headerPointer)
}
unsafeMutableAddress {
return buffer._valuePointer
return buffer._headerPointer
}
}

Expand Down Expand Up @@ -2608,7 +2608,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
}
}
%end
buffer._valuePointer.deinitialize()
buffer._headerPointer.deinitialize()
_fixLifetime(self)
}
}
Expand Down
Loading

0 comments on commit e1e739f

Please sign in to comment.