Skip to content

Commit 2e56ce0

Browse files
committed
Minor perf tweak
1 parent 8393f06 commit 2e56ce0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stdlib/public/core/FloatingPointFromString.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,10 @@ fileprivate func fastParse64(
901901
firstSignificantDigitAfterDecimalPointOffset = i
902902
}
903903
if i < input.count {
904+
// Note: While testing `.description` + `Double(_:String)` against
905+
// random Double values to validate round-trip correctness, almost
906+
// 1/3 of `float_parse64()` is spent in the following loop.
907+
904908
// TODO: Evaluate SIMD or SWAR techniques here...
905909
// In the common case of input such as "1.794373235e+12",
906910
// we should be able to use `input.count - i` to estimate
@@ -959,7 +963,7 @@ fileprivate func fastParse64(
959963
byte = unsafe input[unchecked: i]
960964
}
961965
// Did we scan more than 8 digits in the exponent?
962-
if i - firstExponentDigitOffset > 8 {
966+
if i &- firstExponentDigitOffset > 8 {
963967
// If so, explicitExponent might have overflowed. Scan
964968
// again more carefully to correctly handle both
965969
// "1e0000000000000001" (== 10.0) and "1e99999999999999" (== inf)

0 commit comments

Comments
 (0)