File tree Expand file tree Collapse file tree 1 file changed +1
-16
lines changed Expand file tree Collapse file tree 1 file changed +1
-16
lines changed Original file line number Diff line number Diff line change @@ -1604,31 +1604,16 @@ extension Array {
1604
1604
_makeMutableAndUnique ( )
1605
1605
let count = _buffer. mutableCount
1606
1606
1607
- // Ensure that body can't invalidate the storage or its bounds by
1608
- // moving self into a temporary working array.
1609
- // NOTE: The stack promotion optimization that keys of the
1610
- // "array.withUnsafeMutableBufferPointer" semantics annotation relies on the
1611
- // array buffer not being able to escape in the closure. It can do this
1612
- // because we swap the array buffer in self with an empty buffer here. Any
1613
- // escape via the address of self in the closure will therefore escape the
1614
- // empty array.
1615
-
1616
- var work = Array ( )
1617
- ( work, self ) = ( self , work)
1618
-
1619
1607
// Create an UnsafeBufferPointer over work that we can pass to body
1620
- let pointer = work . _buffer. mutableFirstElementAddress
1608
+ let pointer = _buffer. mutableFirstElementAddress
1621
1609
var inoutBufferPointer = UnsafeMutableBufferPointer (
1622
1610
start: pointer, count: count)
1623
1611
1624
- // Put the working array back before returning.
1625
1612
defer {
1626
1613
_precondition (
1627
1614
inoutBufferPointer. baseAddress == pointer &&
1628
1615
inoutBufferPointer. count == count,
1629
1616
" Array withUnsafeMutableBufferPointer: replacing the buffer is not allowed " )
1630
-
1631
- ( work, self ) = ( self , work)
1632
1617
_endMutation ( )
1633
1618
}
1634
1619
You can’t perform that action at this time.
0 commit comments