@@ -1214,8 +1214,8 @@ extension ${Self} : RangeReplaceableCollection, _ArrayProtocol {
1214
1214
@inline ( never)
1215
1215
internal mutating func _copyToNewBuffer( oldCount: Int ) {
1216
1216
let newCount = oldCount + 1
1217
- var newBuffer = _forceCreateUniqueMutableBuffer (
1218
- & _buffer , countForNewBuffer: oldCount, minNewCapacity: newCount)
1217
+ var newBuffer = _buffer . _forceCreateUniqueMutableBuffer (
1218
+ countForNewBuffer: oldCount, minNewCapacity: newCount)
1219
1219
_buffer. _arrayOutOfPlaceUpdate (
1220
1220
& newBuffer, oldCount, 0 , _IgnorePointer ( ) )
1221
1221
}
@@ -1681,8 +1681,8 @@ internal func _arrayOutOfPlaceReplace<B, C>(
1681
1681
1682
1682
let growth = insertCount - bounds. count
1683
1683
let newCount = source. count + growth
1684
- var newBuffer = _forceCreateUniqueMutableBuffer (
1685
- & source , newCount: newCount, requiredCapacity: newCount)
1684
+ var newBuffer = source . _forceCreateUniqueMutableBuffer (
1685
+ newCount: newCount, requiredCapacity: newCount)
1686
1686
1687
1687
source. _arrayOutOfPlaceUpdate (
1688
1688
& newBuffer,
@@ -1823,58 +1823,60 @@ public func += <
1823
1823
1824
1824
//===--- generic helpers --------------------------------------------------===//
1825
1825
1826
- /// Create a unique mutable buffer that has enough capacity to hold 'newCount'
1827
- /// elements and at least 'requiredCapacity' elements. Set the count of the new
1828
- /// buffer to 'newCount'. The content of the buffer is uninitialized.
1829
- /// The formula used to compute the new buffers capacity is:
1830
- /// max(requiredCapacity, source.capacity) if newCount <= source.capacity
1831
- /// max(requiredCapacity, _growArrayCapacity(source.capacity)) otherwise
1832
- @inline ( never)
1833
- internal func _forceCreateUniqueMutableBuffer< _Buffer : _ArrayBufferProtocol> (
1834
- _ source: inout _Buffer, newCount: Int, requiredCapacity: Int
1835
- ) - > _ContiguousArrayBuffer< _Buffer. Element> {
1836
- return _forceCreateUniqueMutableBufferImpl (
1837
- & source, countForBuffer: newCount, minNewCapacity: newCount,
1838
- requiredCapacity: requiredCapacity)
1839
- }
1840
-
1841
- /// Create a unique mutable buffer that has enough capacity to hold
1842
- /// 'minNewCapacity' elements and set the count of the new buffer to
1843
- /// 'countForNewBuffer'. The content of the buffer uninitialized.
1844
- /// The formula used to compute the new buffers capacity is:
1845
- /// max(minNewCapacity, source.capacity) if minNewCapacity <= source.capacity
1846
- /// max(minNewCapacity, _growArrayCapacity(source.capacity)) otherwise
1847
- @inline ( never)
1848
- internal
1849
- func _forceCreateUniqueMutableBuffer< _Buffer : _ArrayBufferProtocol> (
1850
- _ source: inout _Buffer, countForNewBuffer: Int, minNewCapacity: Int
1851
- ) - > _ContiguousArrayBuffer< _Buffer. Element> {
1852
- return _forceCreateUniqueMutableBufferImpl (
1853
- & source, countForBuffer: countForNewBuffer, minNewCapacity: minNewCapacity,
1854
- requiredCapacity: minNewCapacity)
1855
- }
1856
-
1857
- /// Create a unique mutable buffer that has enough capacity to hold
1858
- /// 'minNewCapacity' elements and at least 'requiredCapacity' elements and set
1859
- /// the count of the new buffer to 'countForBuffer'. The content of the buffer
1860
- /// uninitialized.
1861
- /// The formula used to compute the new capacity is:
1862
- /// max(requiredCapacity, source.capacity) if minNewCapacity <= source.capacity
1863
- /// max(requiredCapacity, _growArrayCapacity(source.capacity)) otherwise
1864
- internal func _forceCreateUniqueMutableBufferImpl< _Buffer : _ArrayBufferProtocol> (
1865
- _ source: inout _Buffer, countForBuffer: Int, minNewCapacity: Int,
1866
- requiredCapacity: Int
1867
- ) - > _ContiguousArrayBuffer< _Buffer. Element> {
1868
- _sanityCheck ( countForBuffer >= 0 )
1869
- _sanityCheck ( requiredCapacity >= countForBuffer)
1870
- _sanityCheck ( minNewCapacity >= countForBuffer)
1871
-
1872
- let minimumCapacity = max (
1873
- requiredCapacity, minNewCapacity > source. capacity
1874
- ? _growArrayCapacity ( source. capacity) : source. capacity)
1875
-
1876
- return _ContiguousArrayBuffer (
1877
- _uninitializedCount: countForBuffer, minimumCapacity: minimumCapacity)
1826
+ extension _ArrayBufferProtocol {
1827
+ /// Create a unique mutable buffer that has enough capacity to hold 'newCount'
1828
+ /// elements and at least 'requiredCapacity' elements. Set the count of the new
1829
+ /// buffer to 'newCount'. The content of the buffer is uninitialized.
1830
+ /// The formula used to compute the new buffers capacity is:
1831
+ /// max(requiredCapacity, source.capacity) if newCount <= source.capacity
1832
+ /// max(requiredCapacity, _growArrayCapacity(source.capacity)) otherwise
1833
+ @inline ( never)
1834
+ internal func _forceCreateUniqueMutableBuffer(
1835
+ newCount: Int , requiredCapacity: Int
1836
+ ) -> _ContiguousArrayBuffer < Element > {
1837
+ return _forceCreateUniqueMutableBufferImpl (
1838
+ countForBuffer: newCount, minNewCapacity: newCount,
1839
+ requiredCapacity: requiredCapacity)
1840
+ }
1841
+
1842
+ /// Create a unique mutable buffer that has enough capacity to hold
1843
+ /// 'minNewCapacity' elements and set the count of the new buffer to
1844
+ /// 'countForNewBuffer'. The content of the buffer uninitialized.
1845
+ /// The formula used to compute the new buffers capacity is:
1846
+ /// max(minNewCapacity, source.capacity) if minNewCapacity <= source.capacity
1847
+ /// max(minNewCapacity, _growArrayCapacity(source.capacity)) otherwise
1848
+ @inline ( never)
1849
+ internal func _forceCreateUniqueMutableBuffer(
1850
+ countForNewBuffer: Int , minNewCapacity: Int
1851
+ ) -> _ContiguousArrayBuffer < Element > {
1852
+ return _forceCreateUniqueMutableBufferImpl (
1853
+ countForBuffer: countForNewBuffer, minNewCapacity: minNewCapacity,
1854
+ requiredCapacity: minNewCapacity)
1855
+ }
1856
+
1857
+ /// Create a unique mutable buffer that has enough capacity to hold
1858
+ /// 'minNewCapacity' elements and at least 'requiredCapacity' elements and set
1859
+ /// the count of the new buffer to 'countForBuffer'. The content of the buffer
1860
+ /// uninitialized.
1861
+ /// The formula used to compute the new capacity is:
1862
+ /// max(requiredCapacity, source.capacity) if minNewCapacity <= source.capacity
1863
+ /// max(requiredCapacity, _growArrayCapacity(source.capacity)) otherwise
1864
+ internal func _forceCreateUniqueMutableBufferImpl(
1865
+ countForBuffer: Int , minNewCapacity: Int ,
1866
+ requiredCapacity: Int
1867
+ ) -> _ContiguousArrayBuffer < Element > {
1868
+ _sanityCheck ( countForBuffer >= 0 )
1869
+ _sanityCheck ( requiredCapacity >= countForBuffer)
1870
+ _sanityCheck ( minNewCapacity >= countForBuffer)
1871
+
1872
+ // FIXME(Typechecker): Swift. prefix shouldn't be necessary (rdar://problem/28947708)
1873
+ let minimumCapacity = Swift . max ( requiredCapacity,
1874
+ minNewCapacity > capacity
1875
+ ? _growArrayCapacity ( capacity) : capacity)
1876
+
1877
+ return _ContiguousArrayBuffer (
1878
+ _uninitializedCount: countForBuffer, minimumCapacity: minimumCapacity)
1879
+ }
1878
1880
}
1879
1881
1880
1882
internal protocol _PointerFunction {
@@ -1993,8 +1995,8 @@ internal func _outlinedMakeUniqueBuffer<_Buffer>(
1993
1995
return
1994
1996
}
1995
1997
1996
- var newBuffer = _forceCreateUniqueMutableBuffer (
1997
- & buffer , newCount: bufferCount, requiredCapacity: bufferCount)
1998
+ var newBuffer = buffer . _forceCreateUniqueMutableBuffer (
1999
+ newCount: bufferCount, requiredCapacity: bufferCount)
1998
2000
buffer. _arrayOutOfPlaceUpdate ( & newBuffer, bufferCount, 0 , _IgnorePointer ( ) )
1999
2001
}
2000
2002
@@ -2014,8 +2016,8 @@ internal func _arrayReserve<_Buffer>(
2014
2016
return
2015
2017
}
2016
2018
2017
- var newBuffer = _forceCreateUniqueMutableBuffer (
2018
- & buffer , newCount: count, requiredCapacity: requiredCapacity)
2019
+ var newBuffer = buffer . _forceCreateUniqueMutableBuffer (
2020
+ newCount: count, requiredCapacity: requiredCapacity)
2019
2021
buffer. _arrayOutOfPlaceUpdate ( & newBuffer, count, 0 , _IgnorePointer ( ) )
2020
2022
}
2021
2023
0 commit comments