Skip to content

Commit 3752e6d

Browse files
committed
move _outlinedMakeUniqueBuffer and _arrayReserve into _ArrayBufferProtocol extension
1 parent 6e841e0 commit 3752e6d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: stdlib/public/core/Arrays.swift.gyb

+8-7
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ extension ${Self} {
15911591
) rethrows -> R {
15921592
let count = self.count
15931593
// Ensure unique storage
1594-
_outlinedMakeUniqueBuffer(&_buffer, bufferCount: count)
1594+
_buffer._outlinedMakeUniqueBuffer(bufferCount: count)
15951595

15961596
// Ensure that body can't invalidate the storage or its bounds by
15971597
// moving self into a temporary working array.
@@ -1985,7 +1985,7 @@ internal struct _IgnorePointer<T> : _PointerFunction {
19851985
extension _ArrayBufferProtocol where Index == Int {
19861986
@_versioned
19871987
@inline(never)
1988-
internal func _outlinedMakeUniqueBuffer(bufferCount: Int) {
1988+
internal mutating func _outlinedMakeUniqueBuffer(bufferCount: Int) {
19891989

19901990
if _fastPath(
19911991
requestUniqueMutableBackingBuffer(minimumCapacity: bufferCount) != nil) {
@@ -1997,13 +1997,14 @@ extension _ArrayBufferProtocol where Index == Int {
19971997
_arrayOutOfPlaceUpdate(&newBuffer, bufferCount, 0, _IgnorePointer())
19981998
}
19991999

2000-
internal func _arrayReserve(_ minimumCapacity: Int) {
2000+
internal mutating func _arrayReserve(_ minimumCapacity: Int) {
20012001

20022002
let count = self.count
2003-
let requiredCapacity = max(count, minimumCapacity)
2003+
// FIXME(Typechecker): shouldn't need Swift. here
2004+
let requiredCapacity = Swift.max(count, minimumCapacity)
20042005

20052006
if _fastPath(
2006-
buffer.requestUniqueMutableBackingBuffer(
2007+
requestUniqueMutableBackingBuffer(
20072008
minimumCapacity: requiredCapacity) != nil
20082009
) {
20092010
return
@@ -2033,7 +2034,7 @@ internal func _arrayAppendSequence<Buffer, S>(
20332034

20342035
// This will force uniqueness
20352036
var count = buffer.count
2036-
_arrayReserve(&buffer, count + 1)
2037+
buffer._arrayReserve(count + 1)
20372038
while true {
20382039
let capacity = buffer.capacity
20392040
let base = buffer.firstElementAddress
@@ -2047,7 +2048,7 @@ internal func _arrayAppendSequence<Buffer, S>(
20472048
if nextItem == nil {
20482049
return
20492050
}
2050-
_arrayReserve(&buffer, _growArrayCapacity(capacity))
2051+
buffer._arrayReserve(_growArrayCapacity(capacity))
20512052
}
20522053
}
20532054

0 commit comments

Comments
 (0)