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 {
16041604 _makeMutableAndUnique ( )
16051605 let count = _buffer. mutableCount
16061606
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-
16191607 // Create an UnsafeBufferPointer over work that we can pass to body
1620- let pointer = work . _buffer. mutableFirstElementAddress
1608+ let pointer = _buffer. mutableFirstElementAddress
16211609 var inoutBufferPointer = UnsafeMutableBufferPointer (
16221610 start: pointer, count: count)
16231611
1624- // Put the working array back before returning.
16251612 defer {
16261613 _precondition (
16271614 inoutBufferPointer. baseAddress == pointer &&
16281615 inoutBufferPointer. count == count,
16291616 " Array withUnsafeMutableBufferPointer: replacing the buffer is not allowed " )
1630-
1631- ( work, self ) = ( self , work)
16321617 _endMutation ( )
16331618 }
16341619
You can’t perform that action at this time.
0 commit comments