@@ -1024,9 +1024,9 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
1024
1024
/// // Prints "["Gold", "Cerise", "Magenta", "Vermillion"]"
1025
1025
///
1026
1026
/// - Parameter s: The sequence of elements to turn into an array.
1027
- public init<
1028
- S : Sequence where S. Iterator . Element == Element
1029
- > ( _ s : S ) {
1027
+ public init< S : Sequence > ( _ s : S )
1028
+ where S. Iterator . Element == Element {
1029
+
1030
1030
self = ${ Self} ( _Buffer ( s. _copyToNativeArrayBuffer ( ) ,
1031
1031
shiftedToStartIndex: 0 ) )
1032
1032
}
@@ -1275,11 +1275,8 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
1275
1275
/// - Parameter newElements: The elements to append to the array.
1276
1276
///
1277
1277
/// - Complexity: O(*n*), where *n* is the length of the resulting array.
1278
- public mutating func append<
1279
- S : Sequence
1280
- where
1281
- S. Iterator. Element == Element
1282
- > ( contentsOf newElements: S ) {
1278
+ public mutating func append< S : Sequence > ( contentsOf newElements: S )
1279
+ where S. Iterator. Element == Element {
1283
1280
let oldCount = self . count
1284
1281
let capacity = self . capacity
1285
1282
let newCount = oldCount + newElements. underestimatedCount
@@ -1309,11 +1306,9 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
1309
1306
/// - Parameter newElements: The elements to append to the array.
1310
1307
///
1311
1308
/// - Complexity: O(*n*), where *n* is the length of the resulting array.
1312
- public mutating func append<
1313
- C : Collection
1314
- where
1315
- C. Iterator. Element == Element
1316
- > ( contentsOf newElements: C ) {
1309
+ public mutating func append< C : Collection > ( contentsOf newElements: C )
1310
+ where C. Iterator. Element == Element {
1311
+
1317
1312
let newElementsCount = numericCast ( newElements. count) as Int
1318
1313
1319
1314
let oldCount = self . count
@@ -1624,14 +1619,17 @@ internal struct _InitializeMemoryFromCollection<
1624
1619
1625
1620
// FIXME(ABI): add argument labels.
1626
1621
@inline ( never)
1627
- internal func _arrayOutOfPlaceReplace<
1628
- B : _ArrayBufferProtocol , C : Collection
1629
- where
1622
+ internal func _arrayOutOfPlaceReplace< B, C> (
1623
+ _ source: inout B ,
1624
+ _ bounds: Range < Int > ,
1625
+ _ newValues: C ,
1626
+ _ insertCount: Int
1627
+ ) where
1628
+ B : _ArrayBufferProtocol ,
1629
+ C : Collection ,
1630
1630
C. Iterator. Element == B . Element ,
1631
- B. Index == Int
1632
- > (
1633
- _ source: inout B , _ bounds: Range < Int > , _ newValues: C , _ insertCount: Int
1634
- ) {
1631
+ B. Index == Int {
1632
+
1635
1633
let growth = insertCount - bounds. count
1636
1634
let newCount = source. count + growth
1637
1635
var newBuffer = _forceCreateUniqueMutableBuffer (
@@ -1694,11 +1692,10 @@ extension ${Self} {
1694
1692
/// array with an empty collection; otherwise, O(*n*), where *n* is the
1695
1693
/// length of the array.
1696
1694
@_semantics ( " array.mutate_unknown " )
1697
- public mutating func replaceSubrange<
1698
- C: Collection where C. Iterator. Element == _Buffer . Element
1699
- > (
1700
- _ subrange: Range < Int > , with newElements: C
1701
- ) {
1695
+ public mutating func replaceSubrange< C> (
1696
+ _ subrange: Range < Int > ,
1697
+ with newElements: C
1698
+ ) where C : Collection , C. Iterator. Element == _Buffer . Element {
1702
1699
_precondition ( subrange. lowerBound >= self . _buffer. startIndex,
1703
1700
" ${Self} replace: subrange start is negative " )
1704
1701
@@ -1839,17 +1836,18 @@ internal protocol _PointerFunction {
1839
1836
/// As an optimization, may move elements out of source rather than
1840
1837
/// copying when it isUniquelyReferenced.
1841
1838
@inline ( never)
1842
- internal func _arrayOutOfPlaceUpdate<
1843
- _Buffer : _ArrayBufferProtocol , Initializer : _PointerFunction
1844
- where Initializer. Element == _Buffer . Element ,
1845
- _Buffer. Index == Int
1846
- > (
1839
+ internal func _arrayOutOfPlaceUpdate< _Buffer, Initializer> (
1847
1840
_ source: inout _Buffer ,
1848
1841
_ dest: inout _ContiguousArrayBuffer < _Buffer . Element > ,
1849
1842
_ headCount: Int , // Count of initial source elements to copy/move
1850
1843
_ newCount: Int , // Number of new elements to insert
1851
1844
_ initializeNewElements: Initializer
1852
- ) {
1845
+ ) where
1846
+ _Buffer : _ArrayBufferProtocol ,
1847
+ Initializer : _PointerFunction ,
1848
+ Initializer. Element == _Buffer . Element ,
1849
+ _Buffer. Index == Int {
1850
+
1853
1851
_sanityCheck ( headCount >= 0 )
1854
1852
_sanityCheck ( newCount >= 0 )
1855
1853
@@ -1931,11 +1929,12 @@ internal struct _IgnorePointer<T> : _PointerFunction {
1931
1929
1932
1930
@_versioned
1933
1931
@inline ( never)
1934
- internal func _outlinedMakeUniqueBuffer<
1935
- _Buffer : _ArrayBufferProtocol where _Buffer. Index == Int
1936
- > (
1932
+ internal func _outlinedMakeUniqueBuffer< _Buffer> (
1937
1933
_ buffer: inout _Buffer , bufferCount: Int
1938
- ) {
1934
+ ) where
1935
+ _Buffer : _ArrayBufferProtocol ,
1936
+ _Buffer. Index == Int {
1937
+
1939
1938
if _fastPath (
1940
1939
buffer. requestUniqueMutableBackingBuffer ( minimumCapacity: bufferCount) != nil ) {
1941
1940
return
@@ -1946,11 +1945,12 @@ internal func _outlinedMakeUniqueBuffer<
1946
1945
_arrayOutOfPlaceUpdate ( & buffer, & newBuffer, bufferCount, 0 , _IgnorePointer ( ) )
1947
1946
}
1948
1947
1949
- internal func _arrayReserve<
1950
- _Buffer : _ArrayBufferProtocol where _Buffer. Index == Int
1951
- > (
1948
+ internal func _arrayReserve< _Buffer> (
1952
1949
_ buffer: inout _Buffer , _ minimumCapacity: Int
1953
- ) {
1950
+ ) where
1951
+ _Buffer : _ArrayBufferProtocol ,
1952
+ _Buffer. Index == Int {
1953
+
1954
1954
let count = buffer. count
1955
1955
let requiredCapacity = max ( count, minimumCapacity)
1956
1956
@@ -1967,29 +1967,28 @@ internal func _arrayReserve<
1967
1967
}
1968
1968
1969
1969
public // SPI(Foundation)
1970
- func _extractOrCopyToNativeArrayBuffer<
1971
- Buffer : _ArrayBufferProtocol
1970
+ func _extractOrCopyToNativeArrayBuffer< Buffer> (
1971
+ _ source: Buffer
1972
+ ) -> _ContiguousArrayBuffer < Buffer . Iterator . Element >
1972
1973
where
1973
- Buffer. Iterator. Element == Buffer . Element
1974
- > ( _ source: Buffer )
1975
- -> _ContiguousArrayBuffer < Buffer . Iterator . Element >
1976
- {
1974
+ Buffer : _ArrayBufferProtocol ,
1975
+ Buffer. Iterator. Element == Buffer . Element {
1976
+
1977
1977
if let n = source. requestNativeBuffer ( ) {
1978
1978
return n
1979
1979
}
1980
1980
return _copyCollectionToNativeArrayBuffer ( source)
1981
1981
}
1982
1982
1983
1983
/// Append items from `newItems` to `buffer`.
1984
- internal func _arrayAppendSequence<
1984
+ internal func _arrayAppendSequence< Buffer, S> (
1985
+ _ buffer: inout Buffer , _ newItems: S
1986
+ ) where
1985
1987
Buffer : _ArrayBufferProtocol ,
1986
- S : Sequence
1987
- where
1988
+ S : Sequence ,
1988
1989
S. Iterator. Element == Buffer . Element ,
1989
- Buffer. Index == Int
1990
- > (
1991
- _ buffer: inout Buffer , _ newItems: S
1992
- ) {
1990
+ Buffer. Index == Int {
1991
+
1993
1992
var stream = newItems. makeIterator ( )
1994
1993
var nextItem = stream. next ( )
1995
1994
@@ -2161,18 +2160,16 @@ extension ${Self} {
2161
2160
}
2162
2161
2163
2162
@available ( * , unavailable, renamed: " replaceSubrange " )
2164
- public mutating func replaceRange<
2165
- C : Collection where C. Iterator. Element == _Buffer . Element
2166
- > ( _ subRange: Range < Int > , with newElements: C ) {
2163
+ public mutating func replaceRange< C> (
2164
+ _ subRange: Range < Int > ,
2165
+ with newElements: C
2166
+ ) where C : Collection , C. Iterator. Element == _Buffer . Element {
2167
2167
Builtin . unreachable ( )
2168
2168
}
2169
2169
2170
2170
@available ( * , unavailable, renamed: " append(contentsOf:) " )
2171
- public mutating func appendContentsOf<
2172
- S : Sequence
2173
- where
2174
- S. Iterator. Element == Element
2175
- > ( _ newElements: S ) {
2171
+ public mutating func appendContentsOf< S : Sequence > ( _ newElements: S )
2172
+ where S. Iterator. Element == Element {
2176
2173
Builtin . unreachable ( )
2177
2174
}
2178
2175
}
0 commit comments