Skip to content

Commit a001a8f

Browse files
committed
Foundation: change Data.Indices to be a CountableRange<Int>, that is much faster than the default
1 parent 055630e commit a001a8f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Foundation/Data.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
149149
public typealias Base64DecodingOptions = NSData.Base64DecodingOptions
150150

151151
public typealias Index = Int
152-
public typealias Indices = DefaultRandomAccessIndices<Data>
152+
public typealias Indices = CountableRange<Int>
153153

154154
internal var _wrapped : _SwiftNSData
155155

@@ -680,6 +680,11 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
680680
public func index(after i: Index) -> Index {
681681
return i + 1
682682
}
683+
684+
685+
public var indices: CountableRange<Int> {
686+
return startIndex..<endIndex
687+
}
683688

684689
/// An iterator over the contents of the data.
685690
///

0 commit comments

Comments
 (0)