Skip to content

Commit cf35c65

Browse files
committed
[stdlib] Generalize Unsafe[Mutable]BufferPointer.indices
1 parent e38c9d1 commit cf35c65

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

stdlib/public/core/UnsafeBufferPointer.swift.gyb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ extension Unsafe${Mutable}BufferPointer where Element: ~Copyable {
255255
@safe
256256
public var endIndex: Int { count }
257257

258+
@inlinable
259+
@_preInverseGenerics
260+
public var indices: Range<Int> {
261+
// Not checked because init forbids negative count.
262+
unsafe Range(uncheckedBounds: (0, count))
263+
}
264+
258265
@inlinable
259266
@_preInverseGenerics
260267
public func index(after i: Int) -> Int {
@@ -684,13 +691,6 @@ extension Unsafe${Mutable}BufferPointer:
684691
_debugPrecondition(range.upperBound <= bounds.upperBound)
685692
}
686693

687-
@inlinable // unsafe-performance
688-
@safe
689-
public var indices: Indices {
690-
// Not checked because init forbids negative count.
691-
return unsafe Indices(uncheckedBounds: (startIndex, endIndex))
692-
}
693-
694694
/// Accesses a contiguous subrange of the buffer's elements.
695695
///
696696
/// The accessed slice uses the same indices for the same elements as the

0 commit comments

Comments
 (0)