Skip to content

Commit def088c

Browse files
committed
stdlib: add underscores to an initializer on ArrayBufferProtocol
1 parent 2a545ea commit def088c

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

stdlib/public/core/ArrayBuffer.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public struct _ArrayBuffer<Element> : _ArrayBufferProtocol {
8383

8484
extension _ArrayBuffer {
8585
/// Adopt the storage of `source`.
86-
public init(_ source: NativeBuffer, shiftedToStartIndex: Int) {
86+
public init(_buffer source: NativeBuffer, shiftedToStartIndex: Int) {
8787
_sanityCheck(shiftedToStartIndex == 0, "shiftedToStartIndex must be 0")
8888
_storage = _ArrayBridgeStorage(native: source._storage)
8989
}
@@ -236,7 +236,7 @@ extension _ArrayBuffer {
236236
let boundsCount = bounds.count
237237
if boundsCount == 0 {
238238
return _SliceBuffer(
239-
_ContiguousArrayBuffer<Element>(),
239+
_buffer: _ContiguousArrayBuffer<Element>(),
240240
shiftedToStartIndex: bounds.lowerBound)
241241
}
242242

@@ -263,7 +263,8 @@ extension _ArrayBuffer {
263263
UnsafeMutablePointer(result.firstElementAddress),
264264
range: _SwiftNSRange(location: bounds.lowerBound, length: boundsCount))
265265

266-
return _SliceBuffer(result, shiftedToStartIndex: bounds.lowerBound)
266+
return _SliceBuffer(
267+
_buffer: result, shiftedToStartIndex: bounds.lowerBound)
267268
}
268269
set {
269270
fatalError("not implemented")

stdlib/public/core/ArrayBufferProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public protocol _ArrayBufferProtocol
2424
init()
2525

2626
/// Adopt the entire buffer, presenting it at the provided `startIndex`.
27-
init(_ buffer: _ContiguousArrayBuffer<Element>, shiftedToStartIndex: Int)
27+
init(_buffer: _ContiguousArrayBuffer<Element>, shiftedToStartIndex: Int)
2828

2929
/// Copy the elements in `bounds` from this buffer into uninitialized
3030
/// memory starting at `target`. Return a pointer "past the end" of the

stdlib/public/core/ArrayCast.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public func _arrayForceCast<SourceElement, TargetElement>(
9090
p += 1
9191
}
9292
}
93-
return Array(_buffer: _ArrayBuffer(buf, shiftedToStartIndex: 0))
93+
return Array(_buffer: _ArrayBuffer(_buffer: buf, shiftedToStartIndex: 0))
9494

9595
case (.value, .explicit):
9696
_sanityCheckFailure(
@@ -169,7 +169,7 @@ ElementwiseBridging:
169169
p.initialize(with: value!)
170170
p += 1
171171
}
172-
return Array(_buffer: _ArrayBuffer(buf, shiftedToStartIndex: 0))
172+
return Array(_buffer: _ArrayBuffer(_buffer: buf, shiftedToStartIndex: 0))
173173
}
174174
while false
175175

stdlib/public/core/Arrays.swift.gyb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,8 @@ public struct ${Self}<Element>
794794
buffer._copyContents(
795795
subRange: Range(buffer.indices),
796796
initializing: newBuffer.firstElementAddress)
797-
buffer = _Buffer(newBuffer, shiftedToStartIndex: buffer.startIndex)
797+
buffer = _Buffer(
798+
_buffer: newBuffer, shiftedToStartIndex: buffer.startIndex)
798799
}
799800

800801
@_semantics("array.make_mutable")
@@ -893,8 +894,8 @@ public struct ${Self}<Element>
893894
/// Initialization from an existing buffer does not have "array.init"
894895
/// semantics because the caller may retain an alias to buffer.
895896
public // @testable
896-
init(_buffer: _ContiguousArrayBuffer<Element>) {
897-
self.init(_buffer: _Buffer(_buffer, shiftedToStartIndex: 0))
897+
init(_buffer buffer: _ContiguousArrayBuffer<Element>) {
898+
self.init(_buffer: _Buffer(_buffer: buffer, shiftedToStartIndex: 0))
898899
}
899900
%end
900901

@@ -1038,8 +1039,9 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
10381039
where S.Iterator.Element == Element {
10391040

10401041
self = ${Self}(
1041-
_buffer: _Buffer(s._copyToContiguousArray()._buffer,
1042-
shiftedToStartIndex: 0))
1042+
_buffer: _Buffer(
1043+
_buffer: s._copyToContiguousArray()._buffer,
1044+
shiftedToStartIndex: 0))
10431045
}
10441046

10451047
/// Creates a new array containing the specified number of a single, repeated
@@ -1072,7 +1074,7 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
10721074
) -> _Buffer {
10731075
let newBuffer = _ContiguousArrayBuffer<Element>(
10741076
uninitializedCount: 0, minimumCapacity: minimumCapacity)
1075-
return _Buffer(newBuffer, shiftedToStartIndex: 0)
1077+
return _Buffer(_buffer: newBuffer, shiftedToStartIndex: 0)
10761078
}
10771079

10781080
/// Construct a ${Self} of `count` uninitialized elements.
@@ -1125,7 +1127,8 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
11251127
storage, to: _ContiguousArrayStorage<Element>.self))
11261128

11271129
return (
1128-
Array(_buffer: _Buffer(innerBuffer, shiftedToStartIndex: 0)),
1130+
Array(
1131+
_buffer: _Buffer(_buffer: innerBuffer, shiftedToStartIndex: 0)),
11291132
innerBuffer.firstElementAddress)
11301133
}
11311134

@@ -1210,7 +1213,8 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
12101213
_buffer._copyContents(
12111214
subRange: Range(_buffer.indices),
12121215
initializing: newBuffer.firstElementAddress)
1213-
_buffer = _Buffer(newBuffer, shiftedToStartIndex: _buffer.startIndex)
1216+
_buffer = _Buffer(
1217+
_buffer: newBuffer, shiftedToStartIndex: _buffer.startIndex)
12141218
}
12151219
_sanityCheck(capacity >= minimumCapacity)
12161220
}
@@ -1916,7 +1920,7 @@ internal func _arrayOutOfPlaceUpdate<_Buffer, Initializer>(
19161920
let tailEnd = source.endIndex
19171921
source._copyContents(subRange: tailStart..<tailEnd, initializing: newEnd)
19181922
}
1919-
source = _Buffer(dest, shiftedToStartIndex: source.startIndex)
1923+
source = _Buffer(_buffer: dest, shiftedToStartIndex: source.startIndex)
19201924
}
19211925

19221926
internal struct _InitializePointer<T> : _PointerFunction {

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
287287
_uncheckedUnsafeBufferObject: _emptyArrayStorage)
288288
}
289289

290-
public init(_ buffer: _ContiguousArrayBuffer, shiftedToStartIndex: Int) {
290+
public init(_buffer buffer: _ContiguousArrayBuffer, shiftedToStartIndex: Int) {
291291
_sanityCheck(shiftedToStartIndex == 0, "shiftedToStartIndex must be 0")
292292
self = buffer
293293
}

stdlib/public/core/SliceBuffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
3737
_invariantCheck()
3838
}
3939

40-
public init(_ buffer: NativeBuffer, shiftedToStartIndex: Int) {
40+
public init(_buffer buffer: NativeBuffer, shiftedToStartIndex: Int) {
4141
let shift = buffer.startIndex - shiftedToStartIndex
4242
self.init(
4343
owner: buffer.owner,

0 commit comments

Comments
 (0)