Skip to content

Commit b26fc44

Browse files
committed
stdlib: add underscores to an initializer on ArrayBufferProtocol
1 parent 6cdbacc commit b26fc44

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-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: 14 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

@@ -1037,8 +1038,10 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
10371038
public init<S : Sequence>(_ s: S)
10381039
where S.Iterator.Element == Element {
10391040

1040-
self = ${Self}(_buffer: _Buffer(s._copyToNativeArrayBuffer(),
1041-
shiftedToStartIndex: 0))
1041+
self = ${Self}(
1042+
_buffer: _Buffer(
1043+
_buffer: s._copyToNativeArrayBuffer(),
1044+
shiftedToStartIndex: 0))
10421045
}
10431046

10441047
/// Creates a new array containing the specified number of a single, repeated
@@ -1071,7 +1074,7 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
10711074
) -> _Buffer {
10721075
let newBuffer = _ContiguousArrayBuffer<Element>(
10731076
uninitializedCount: 0, minimumCapacity: minimumCapacity)
1074-
return _Buffer(newBuffer, shiftedToStartIndex: 0)
1077+
return _Buffer(_buffer: newBuffer, shiftedToStartIndex: 0)
10751078
}
10761079

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

11261129
return (
1127-
Array(_buffer: _Buffer(innerBuffer, shiftedToStartIndex: 0)),
1130+
Array(
1131+
_buffer: _Buffer(_buffer: innerBuffer, shiftedToStartIndex: 0)),
11281132
innerBuffer.firstElementAddress)
11291133
}
11301134

@@ -1209,7 +1213,8 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
12091213
_buffer._copyContents(
12101214
subRange: Range(_buffer.indices),
12111215
initializing: newBuffer.firstElementAddress)
1212-
_buffer = _Buffer(newBuffer, shiftedToStartIndex: _buffer.startIndex)
1216+
_buffer = _Buffer(
1217+
_buffer: newBuffer, shiftedToStartIndex: _buffer.startIndex)
12131218
}
12141219
_sanityCheck(capacity >= minimumCapacity)
12151220
}
@@ -1913,7 +1918,7 @@ internal func _arrayOutOfPlaceUpdate<_Buffer, Initializer>(
19131918
let tailEnd = source.endIndex
19141919
source._copyContents(subRange: tailStart..<tailEnd, initializing: newEnd)
19151920
}
1916-
source = _Buffer(dest, shiftedToStartIndex: source.startIndex)
1921+
source = _Buffer(_buffer: dest, shiftedToStartIndex: source.startIndex)
19171922
}
19181923

19191924
internal struct _InitializePointer<T> : _PointerFunction {

stdlib/public/core/ContiguousArrayBuffer.swift

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

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

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)