stdlib: implement nativeOwner in all array buffers to avoid %else in Arrays.swift.gyb. NFC.

Swift SVN r27133
This commit is contained in:
Erik Eckstein
2015-04-08 19:48:48 +00:00
parent d79078a391
commit 43d41147a6
4 changed files with 20 additions and 13 deletions

View File

@@ -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`