Skip to content

Commit 125823d

Browse files
author
Dave Abrahams
committed
[stdlib] ManagedBuffer: rename Value => Header
This implements SE-0114 Updating Buffer "Value" Names to "Header" Names https://github.com/apple/swift-evolution/blob/master/proposals/0114-buffer-naming.md
1 parent 5cf6006 commit 125823d

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
@@ -238,7 +238,7 @@ public struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
238238
let verbatim = false
239239
#endif
240240

241-
__bufferPointer._valuePointer.initialize(with:
241+
__bufferPointer._headerPointer.initialize(with:
242242
_ArrayBody(
243243
count: count,
244244
capacity: capacity,
@@ -342,7 +342,7 @@ public struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
342342
/// The number of elements the buffer stores.
343343
public var count: Int {
344344
get {
345-
return __bufferPointer.value.count
345+
return __bufferPointer.header.count
346346
}
347347
nonmutating set {
348348
_sanityCheck(newValue >= 0)
@@ -351,7 +351,7 @@ public struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
351351
newValue <= capacity,
352352
"Can't grow an array buffer past its capacity")
353353

354-
__bufferPointer._valuePointer.pointee.count = newValue
354+
__bufferPointer._headerPointer.pointee.count = newValue
355355
}
356356
}
357357

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

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

373373
/// 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)