stdlib: Implement "_isValidSubscript(_:hoistedIsNativeNoTypeCheckBuffer:)" for ContiguousArrayBuffer.

ContiguousArrayBuffer is used as the buffer for Array when ObjC interop is disabled, so even though there's no behavior difference from "_isValidSubscript(_:hoistedIsNativeBuffer:)" for a ContiguousArrayBuffer, we want the interface to be interchangeable with the one for the bridgeable ArrayBuffer.

Swift SVN r27409
This commit is contained in:
Joe Groff
2015-04-17 05:30:21 +00:00
parent 92636a4a64
commit 82aa6e720e

View File

@@ -362,6 +362,19 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
return (index >= 0) && (index < __bufferPointer.value.count)
}
/// Return whether the given `index` is valid for subscripting, i.e. `0
/// index < count`
///
/// For ContiguousArrayBuffer, this is equivalent to the
/// `_isValidSubscript(_:hoistedIsNativeBuffer:)` form, but is necessary
/// for interface parity with `ArrayBuffer`.
@inline(__always)
func _isValidSubscript(index : Int, hoistedIsNativeNoTypeCheckBuffer : Bool)
-> Bool {
return _isValidSubscript(index,
hoistedIsNativeNoTypeCheckBuffer : hoistedIsNativeNoTypeCheckBuffer)
}
/// How many elements the buffer can store without reallocation
public var capacity: Int {
return __bufferPointer.value.capacity