mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib: implement nativeOwner in all array buffers to avoid %else in Arrays.swift.gyb. NFC.
Swift SVN r27133
This commit is contained in:
@@ -307,6 +307,12 @@ public struct ${Self}<T> : _CollectionType, MutableCollectionType, Sliceable, _D
|
||||
return _buffer.capacity
|
||||
}
|
||||
|
||||
// Requires: the array has a native buffer
|
||||
@semantics("array.owner")
|
||||
func _getOwner() -> Builtin.NativeObject {
|
||||
return Builtin.castToNativeObject(_buffer.nativeOwner)
|
||||
}
|
||||
|
||||
// Don't inline copyBuffer - this would inline the copy loop into the current
|
||||
// path preventing retains/releases to be matched accross that region.
|
||||
@inline(never)
|
||||
@@ -355,19 +361,6 @@ public struct ${Self}<T> : _CollectionType, MutableCollectionType, Sliceable, _D
|
||||
hoistedIsNativeNoTypeCheckBuffer: hoistedIsNativeNoTypeCheckBuffer),
|
||||
"${Self} index out of range")
|
||||
}
|
||||
|
||||
// Requires: the array has a native buffer
|
||||
@semantics("array.owner")
|
||||
func _getOwner() -> Builtin.NativeObject {
|
||||
return Builtin.castToNativeObject(_buffer.nativeOwner)
|
||||
}
|
||||
%else:
|
||||
|
||||
// Requires: the array has a native buffer
|
||||
@semantics("array.owner")
|
||||
func _getOwner() -> Builtin.NativeObject {
|
||||
return Builtin.castToNativeObject(_buffer.owner)
|
||||
}
|
||||
%end
|
||||
|
||||
/// Check that the given `index` is valid, i.e. `0 ≤ index ≤ count`
|
||||
|
||||
Reference in New Issue
Block a user