Skip to content

Commit e1e739f

Browse files
author
Dave Abrahams
authored
Merge pull request #3374 from apple/SE-0114
[stdlib] ManagedBuffer: rename Value => Header
2 parents 5c2cda0 + 125823d commit e1e739f

File tree

4 files changed

+113
-113
lines changed

4 files changed

+113
-113
lines changed

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorage1 {
102102

103103
deinit {
104104
__manager._elementPointer.deinitialize(
105-
count: __manager._valuePointer.pointee.count)
106-
__manager._valuePointer.deinitialize()
105+
count: __manager._headerPointer.pointee.count)
106+
__manager._headerPointer.deinitialize()
107107
_fixLifetime(__manager)
108108
}
109109

@@ -114,7 +114,7 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorage1 {
114114
_ body: @noescape (UnsafeBufferPointer<AnyObject>) throws -> Void
115115
) rethrows {
116116
if _isBridgedVerbatimToObjectiveC(Element.self) {
117-
let count = __manager.value.count
117+
let count = __manager.header.count
118118
let elements = UnsafePointer<AnyObject>(__manager._elementPointer)
119119
defer { _fixLifetime(__manager) }
120120
try body(UnsafeBufferPointer(start: elements, count: count))
@@ -128,7 +128,7 @@ final class _ContiguousArrayStorage<Element> : _ContiguousArrayStorage1 {
128128
_sanityCheck(
129129
!_isBridgedVerbatimToObjectiveC(Element.self),
130130
"Verbatim bridging should be handled separately")
131-
return __manager.value.count
131+
return __manager.header.count
132132
}
133133

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

242-
__bufferPointer._valuePointer.initialize(with:
242+
__bufferPointer._headerPointer.initialize(with:
243243
_ArrayBody(
244244
count: count,
245245
capacity: capacity,
@@ -343,7 +343,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
343343
/// The number of elements the buffer stores.
344344
public var count: Int {
345345
get {
346-
return __bufferPointer.value.count
346+
return __bufferPointer.header.count
347347
}
348348
nonmutating set {
349349
_sanityCheck(newValue >= 0)
@@ -352,7 +352,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
352352
newValue <= capacity,
353353
"Can't grow an array buffer past its capacity")
354354

355-
__bufferPointer._valuePointer.pointee.count = newValue
355+
__bufferPointer._headerPointer.pointee.count = newValue
356356
}
357357
}
358358

@@ -361,14 +361,14 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
361361
@inline(__always)
362362
func _checkValidSubscript(_ index : Int) {
363363
_precondition(
364-
(index >= 0) && (index < __bufferPointer.value.count),
364+
(index >= 0) && (index < __bufferPointer.header.count),
365365
"Index out of range"
366366
)
367367
}
368368

369369
/// The number of elements the buffer can store without reallocation.
370370
public var capacity: Int {
371-
return __bufferPointer.value.capacity
371+
return __bufferPointer.header.capacity
372372
}
373373

374374
/// Copy the elements in `bounds` from this buffer into uninitialized

stdlib/public/core/HashedCollections.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,10 +2505,10 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
25052505
// This API is unsafe and needs a `_fixLifetime` in the caller.
25062506
internal var _body: _HashedContainerStorageHeader {
25072507
unsafeAddress {
2508-
return UnsafePointer(buffer._valuePointer)
2508+
return UnsafePointer(buffer._headerPointer)
25092509
}
25102510
unsafeMutableAddress {
2511-
return buffer._valuePointer
2511+
return buffer._headerPointer
25122512
}
25132513
}
25142514

@@ -2608,7 +2608,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
26082608
}
26092609
}
26102610
%end
2611-
buffer._valuePointer.deinitialize()
2611+
buffer._headerPointer.deinitialize()
26122612
_fixLifetime(self)
26132613
}
26142614
}

0 commit comments

Comments
 (0)