@@ -1666,29 +1666,26 @@ internal struct _InitializeMemoryFromCollection<
1666
1666
var newValues : C
1667
1667
}
1668
1668
1669
- // FIXME(ABI)#14 : add argument labels.
1670
- @inline ( never)
1671
- internal func _arrayOutOfPlaceReplace< B, C> (
1672
- _ source: inout B,
1673
- _ bounds: Range < Int > ,
1674
- _ newValues: C,
1675
- _ insertCount: Int
1676
- ) where
1677
- B : _ArrayBufferProtocol,
1678
- C : Collection,
1679
- C . Iterator. Element == B . Element,
1680
- B . Index == Int {
1681
-
1682
- let growth = insertCount - bounds. count
1683
- let newCount = source. count + growth
1684
- var newBuffer = source. _forceCreateUniqueMutableBuffer (
1685
- newCount: newCount, requiredCapacity: newCount)
1686
-
1687
- source. _arrayOutOfPlaceUpdate (
1688
- & newBuffer,
1689
- bounds. lowerBound - source. startIndex, insertCount,
1690
- _InitializeMemoryFromCollection ( newValues)
1691
- )
1669
+ extension _ArrayBufferProtocol where Index == Int {
1670
+ // FIXME(ABI)#14 : add argument labels.
1671
+ @inline ( never)
1672
+ internal mutating func _arrayOutOfPlaceReplace< C : Collection > (
1673
+ _ bounds: Range < Int > ,
1674
+ _ newValues: C ,
1675
+ _ insertCount: Int
1676
+ ) where C. Iterator. Element == Element {
1677
+
1678
+ let growth = insertCount - bounds. count
1679
+ let newCount = count + growth
1680
+ var newBuffer = _forceCreateUniqueMutableBuffer (
1681
+ newCount: newCount, requiredCapacity: newCount)
1682
+
1683
+ _arrayOutOfPlaceUpdate (
1684
+ & newBuffer,
1685
+ bounds. lowerBound - startIndex, insertCount,
1686
+ _InitializeMemoryFromCollection ( newValues)
1687
+ )
1688
+ }
1692
1689
}
1693
1690
1694
1691
/// A _debugPrecondition check that `i` has exactly reached the end of
@@ -1767,7 +1764,7 @@ extension ${Self} {
1767
1764
self . _buffer. replace (
1768
1765
subRange: subrange, with: insertCount, elementsOf: newElements)
1769
1766
} else {
1770
- _arrayOutOfPlaceReplace ( & self . _buffer , subrange, newElements, insertCount)
1767
+ _buffer . _arrayOutOfPlaceReplace ( subrange, newElements, insertCount)
1771
1768
}
1772
1769
}
1773
1770
}
0 commit comments