Skip to content

Commit f62c2c9

Browse files
committed
Sink down the internal word index enum, fiddle with some switches
1 parent 1d80829 commit f62c2c9

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

test/Prototypes/DoubleWidth.swift.gyb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,16 @@ extension DoubleWidth {
237237
self._low = value._storage.low.words
238238
_sanityCheck(!_low.isEmpty)
239239
}
240-
241-
internal enum _WordsIndexValue: Equatable {
242-
case low(Low.Words.Index)
243-
case high(High.Words.Index)
244-
}
245240
}
246241
}
247242

248-
extension DoubleWidth.Words {
243+
extension DoubleWidth.Words {
249244
public struct Index {
245+
internal enum _WordsIndexValue: Equatable {
246+
case low(DoubleWidth.Low.Words.Index)
247+
case high(DoubleWidth.High.Words.Index)
248+
}
249+
250250
internal var _value: _WordsIndexValue
251251

252252
internal init(_ _value: _WordsIndexValue) { self._value = _value }
@@ -259,8 +259,8 @@ extension DoubleWidth.Words.Index: Comparable {
259259
public static func <(lhs: DoubleWidth.Words.Index, rhs: DoubleWidth.Words.Index) -> Bool {
260260
switch (lhs._value, rhs._value) {
261261
case let (.low(l), .low(r)): return l < r
262-
case (.low(_), .high(_)): return true
263-
case (.high(_), .low(_)): return false
262+
case (.low, .high): return true
263+
case (.high, .low): return false
264264
case let (.high(l), .high(r)): return l < r
265265
}
266266
}
@@ -282,15 +282,15 @@ extension DoubleWidth.Words: Collection {
282282

283283
public func index(after i: Index) -> Index {
284284
switch i._value {
285+
case let .low(li) where Base.bitWidth < UInt.bitWidth:
286+
return Index(.high(_high.endIndex))
285287
case let .low(li):
286-
if Base.bitWidth < UInt.bitWidth {
287-
return Index(.high(_high.endIndex))
288-
}
289288
let next = _low.index(after: li)
290289
if next == _low.endIndex {
291290
return Index(.high(_high.startIndex))
291+
} else {
292+
return Index(.low(next))
292293
}
293-
return Index(.low(next))
294294
case let .high(hi):
295295
return Index(.high(_high.index(after: hi)))
296296
}

0 commit comments

Comments
 (0)