mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[stdlib] indexing model: Interval/Range merge
This is step 1; we still need to introduce ClosedRange.
This commit is contained in:
@@ -57,7 +57,7 @@ var unicodeScalarRanges: [Range<UInt32>] = [UInt32(0)...0xd7ff, 0xe000...0x10fff
|
||||
var unicodeScalarCount: Int {
|
||||
var count = 0
|
||||
for r in unicodeScalarRanges {
|
||||
count += Int(r.endIndex - r.startIndex)
|
||||
count += Int(r.upperBound - r.lowerBound)
|
||||
}
|
||||
return count
|
||||
}
|
||||
@@ -65,9 +65,9 @@ var unicodeScalarCount: Int {
|
||||
func nthUnicodeScalar(n: UInt32) -> UnicodeScalar {
|
||||
var count: UInt32 = 0
|
||||
for r in unicodeScalarRanges {
|
||||
count += r.endIndex - r.startIndex
|
||||
count += r.upperBound - r.lowerBound
|
||||
if count > n {
|
||||
return UnicodeScalar(r.endIndex - (count - n))
|
||||
return UnicodeScalar(r.upperBound - (count - n))
|
||||
}
|
||||
}
|
||||
_preconditionFailure("Index out of range")
|
||||
|
||||
Reference in New Issue
Block a user