File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ internal func _parseAsciiAsUIntMax(
76
76
// Parse (optional) sign
77
77
let (digitsUTF16, hasMinus) = _parseOptionalAsciiSign(utf16)
78
78
// Parse digits
79
- guard let result = _parseUnsignedAsciiAsUIntMax(digitsUTF16, radix, maximum) else { return nil }
79
+ guard let result = _parseUnsignedAsciiAsUIntMax(digitsUTF16, radix, maximum)
80
+ else { return nil }
80
81
// Disallow < 0
81
82
if hasMinus && result != 0 { return nil }
82
83
// Return
@@ -96,9 +97,11 @@ internal func _parseAsciiAsIntMax(
96
97
if utf16.isEmpty { return nil }
97
98
// Parse (optional) sign
98
99
let (digitsUTF16, hasMinus) = _parseOptionalAsciiSign(utf16)
99
- // Parse digits
100
- let absValueMax = UIntMax(bitPattern: maximum) + (hasMinus ? 1 : 0) // E.g. Int8's range is -128...127
101
- guard let absValue = _parseUnsignedAsciiAsUIntMax(digitsUTF16, radix, absValueMax) else { return nil }
100
+ // Parse digits. +1 for negatives because e.g. Int8's range is -128...127.
101
+ let absValueMax = UIntMax(bitPattern: maximum) + (hasMinus ? 1 : 0)
102
+ guard let absValue =
103
+ _parseUnsignedAsciiAsUIntMax(digitsUTF16, radix, absValueMax)
104
+ else { return nil }
102
105
// Return signed result
103
106
return IntMax(bitPattern: hasMinus ? 0 &- absValue : absValue)
104
107
}
You can’t perform that action at this time.
0 commit comments