Skip to content

Commit 75fb174

Browse files
committed
Foundation: change Data.Indices to be a CountableRange<Int>, that is much faster than the default
1 parent 573ed96 commit 75fb174

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
8181
public typealias Base64DecodingOptions = NSData.Base64DecodingOptions
8282

8383
public typealias Index = Int
84-
public typealias Indices = DefaultRandomAccessIndices<Data>
84+
public typealias Indices = CountableRange<Int>
8585

8686
internal var _wrapped : _SwiftNSData
8787

@@ -642,6 +642,10 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
642642
return i + 1
643643
}
644644

645+
public var indices: CountableRange<Int> {
646+
return startIndex..<endIndex
647+
}
648+
645649
/// An iterator over the contents of the data.
646650
///
647651
/// The iterator will increment byte-by-byte.

0 commit comments

Comments
 (0)