mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user