Closed oscbyspro closed 6 days ago
I'll disambiguate the following BinaryInteger.init(load:) cases:
let ix = IX.random()
let ux = UX.random()
IX(load: InfiniInt<IX>(load: ix))
IX(load: InfiniInt<UX>(load: ix))
UX(load: InfiniInt<IX>(load: ux))
UX(load: InfiniInt<UX>(load: ux))
IX(load: DoubleInt<IX>(load: ix))
IX(load: DoubleInt<UX>(load: ix))
UX(load: DoubleInt<IX>(load: ux))
UX(load: DoubleInt<UX>(load: ux))
I'll rename T.Failure as T.Error. I see it as Value & Error vs Success & Failure and I want to be consistent about it.
Seems silly, but going from A
to B
improves decoding performance ~2x (for small integers).
// MARK: A (slow)
try description.withUTF8(self.decode)
// MARK: B (fast)
try description.withUTF8 {
try self.decode($0)
}
The GCD stuff is a bit awkward to use in some generic contexts. I'll have a look a that, and perhaps hoist them like ilog2() and isqrt(). I also think it would be better if guarantee types mimicked their payload types w.r.t. instance vs static methods.
Hm. Seems like I'll have to correct some change-of-sign stuff now that BinaryInteger/bezout(_:) permits signed values.
I'll make TextInt
's initializers generic over BinaryInteger
but keep the UX
default. I'll also change the radix
output type to U8
. The preferred concrete types minimize the need for size-related validation. The generics will remove the need for explicit type conversions.
I'll add the following convenience conversions, which I performed manually in (#83).
extension BinaryInteger {
@inlinable public static func exactly<Other>(
_ source: consuming Fallible<Other>
) -> Fallible<Self> where Other: BinaryInteger { ... }
@inlinable public static func exactly<Other>(
sign: consuming Sign = .plus,
magnitude: consuming Fallible<Other>
) -> Fallible<Self> where Other: UnsignedInteger { ... }
}
These should really be borrowing
but that is not quite possible in ≤ Swift 5.10
.
I'll use this thread to document various minor changes.