File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ extension __SwiftNativeNSArrayWithContiguousStorage: _NSArrayCore {
254
254
255
255
@objc ( exchangeObjectAtIndex: withObjectAtIndex: )
256
256
dynamic internal func exchange( at index: Int , with index2: Int ) {
257
- swap ( & contents[ index] , & contents [ index2] )
257
+ contents. swapAt ( index, index2)
258
258
}
259
259
260
260
@objc ( replaceObjectsInRange: withObjects: count: )
@@ -263,7 +263,13 @@ extension __SwiftNativeNSArrayWithContiguousStorage: _NSArrayCore {
263
263
count: Int ) {
264
264
let range = range. location ..< range. location + range. length
265
265
let buf = UnsafeBufferPointer ( start: objects, count: count)
266
- contents. replaceSubrange ( range, with: buf)
266
+ if range == contents. startIndex..< contents. endIndex {
267
+ contents = Array ( buf)
268
+ } else {
269
+ // We make an Array here to make sure that something is holding onto the
270
+ // objects in `buf`, since replaceSubrange could release them
271
+ contents. replaceSubrange ( range, with: Array ( buf) )
272
+ }
267
273
}
268
274
269
275
@objc ( insertObjects: count: atIndex: )
You can’t perform that action at this time.
0 commit comments