Skip to content

Commit 21b4df8

Browse files
committed
wip: internalize more
1 parent 2fde74a commit 21b4df8

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

stdlib/public/core/Arrays.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ public struct ${Self}<Element>
897897
}
898898
%end
899899

900+
@_versioned
900901
internal var _buffer: _Buffer
901902
}
902903

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
264264

265265
/// Call `body(p)`, where `p` is an `UnsafeBufferPointer` over the
266266
/// underlying contiguous storage.
267-
public func withUnsafeBufferPointer<R>(
267+
internal func withUnsafeBufferPointer<R>(
268268
_ body: @noescape (UnsafeBufferPointer<Element>) throws -> R
269269
) rethrows -> R {
270270
defer { _fixLifetime(self) }
@@ -274,7 +274,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
274274

275275
/// Call `body(p)`, where `p` is an `UnsafeMutableBufferPointer`
276276
/// over the underlying contiguous storage.
277-
public mutating func withUnsafeMutableBufferPointer<R>(
277+
internal mutating func withUnsafeMutableBufferPointer<R>(
278278
_ body: @noescape (UnsafeMutableBufferPointer<Element>) throws -> R
279279
) rethrows -> R {
280280
defer { _fixLifetime(self) }
@@ -284,7 +284,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
284284

285285
//===--- _ArrayBufferProtocol conformance -----------------------------------===//
286286
/// Create an empty buffer.
287-
public init() {
287+
internal init() {
288288
__bufferPointer = ManagedBufferPointer(
289289
_uncheckedUnsafeBufferObject: _emptyArrayStorage)
290290
}
@@ -294,7 +294,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
294294
self = buffer
295295
}
296296

297-
public mutating func requestUniqueMutableBackingBuffer(
297+
internal mutating func requestUniqueMutableBackingBuffer(
298298
minimumCapacity: Int
299299
) -> _ContiguousArrayBuffer<Element>? {
300300
if _fastPath(isUniquelyReferenced() && capacity >= minimumCapacity) {
@@ -303,29 +303,29 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
303303
return nil
304304
}
305305

306-
public mutating func isMutableAndUniquelyReferenced() -> Bool {
306+
internal mutating func isMutableAndUniquelyReferenced() -> Bool {
307307
return isUniquelyReferenced()
308308
}
309309

310-
public mutating func isMutableAndUniquelyReferencedOrPinned() -> Bool {
310+
internal mutating func isMutableAndUniquelyReferencedOrPinned() -> Bool {
311311
return isUniquelyReferencedOrPinned()
312312
}
313313

314314
/// If this buffer is backed by a `_ContiguousArrayBuffer`
315315
/// containing the same number of elements as `self`, return it.
316316
/// Otherwise, return `nil`.
317-
public func requestNativeBuffer() -> _ContiguousArrayBuffer<Element>? {
317+
internal func requestNativeBuffer() -> _ContiguousArrayBuffer<Element>? {
318318
return self
319319
}
320320

321321
@_versioned
322-
func getElement(_ i: Int) -> Element {
322+
internal func getElement(_ i: Int) -> Element {
323323
_sanityCheck(i >= 0 && i < count, "Array index out of range")
324324
return firstElementAddress[i]
325325
}
326326

327327
/// Get or set the value of the ith element.
328-
public subscript(i: Int) -> Element {
328+
internal subscript(i: Int) -> Element {
329329
get {
330330
return getElement(i)
331331
}
@@ -343,7 +343,7 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
343343
}
344344

345345
/// The number of elements the buffer stores.
346-
public var count: Int {
346+
internal var count: Int {
347347
get {
348348
return __bufferPointer.header.count
349349
}
@@ -369,15 +369,15 @@ internal struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
369369
}
370370

371371
/// The number of elements the buffer can store without reallocation.
372-
public var capacity: Int {
372+
internal var capacity: Int {
373373
return __bufferPointer.header.capacity
374374
}
375375

376376
/// Copy the elements in `bounds` from this buffer into uninitialized
377377
/// memory starting at `target`. Return a pointer "past the end" of the
378378
/// just-initialized memory.
379379
@discardableResult
380-
public func _copyContents(
380+
internal func _copyContents(
381381
subRange bounds: Range<Int>,
382382
initializing target: UnsafeMutablePointer<Element>
383383
) -> UnsafeMutablePointer<Element> {
@@ -528,19 +528,19 @@ extension _ContiguousArrayBuffer : RandomAccessCollection {
528528
/// The position of the first element in a non-empty collection.
529529
///
530530
/// In an empty collection, `startIndex == endIndex`.
531-
public var startIndex: Int {
531+
internal var startIndex: Int {
532532
return 0
533533
}
534534
/// The collection's "past the end" position.
535535
///
536536
/// `endIndex` is not a valid argument to `subscript`, and is always
537537
/// reachable from `startIndex` by zero or more applications of
538538
/// `index(after:)`.
539-
public var endIndex: Int {
539+
internal var endIndex: Int {
540540
return count
541541
}
542542

543-
public typealias Indices = CountableRange<Int>
543+
internal typealias Indices = CountableRange<Int>
544544
}
545545

546546
extension Sequence {
@@ -575,13 +575,13 @@ internal func _copySequenceToContiguousArray<
575575
}
576576

577577
extension Collection {
578-
public func _copyToContiguousArray() -> ContiguousArray<Iterator.Element> {
578+
internal func _copyToContiguousArray() -> ContiguousArray<Iterator.Element> {
579579
return _copyCollectionToContiguousArray(self)
580580
}
581581
}
582582

583583
extension _ContiguousArrayBuffer {
584-
public func _copyToContiguousArray() -> ContiguousArray<Element> {
584+
internal func _copyToContiguousArray() -> ContiguousArray<Element> {
585585
return ContiguousArray(_buffer: self)
586586
}
587587
}

0 commit comments

Comments
 (0)