Skip to content

Commit 02a4b58

Browse files
authored
Rollup merge of #77921 - wcampbell0x2a:f64-collapsible-if, r=jyn514
f64: Refactor collapsible_if
2 parents 439ea4b + 096722f commit 02a4b58

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

library/std/src/f64.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -920,22 +920,20 @@ impl f64 {
920920
fn log_wrapper<F: Fn(f64) -> f64>(self, log_fn: F) -> f64 {
921921
if !cfg!(any(target_os = "solaris", target_os = "illumos")) {
922922
log_fn(self)
923-
} else {
924-
if self.is_finite() {
925-
if self > 0.0 {
926-
log_fn(self)
927-
} else if self == 0.0 {
928-
Self::NEG_INFINITY // log(0) = -Inf
929-
} else {
930-
Self::NAN // log(-n) = NaN
931-
}
932-
} else if self.is_nan() {
933-
self // log(NaN) = NaN
934-
} else if self > 0.0 {
935-
self // log(Inf) = Inf
923+
} else if self.is_finite() {
924+
if self > 0.0 {
925+
log_fn(self)
926+
} else if self == 0.0 {
927+
Self::NEG_INFINITY // log(0) = -Inf
936928
} else {
937-
Self::NAN // log(-Inf) = NaN
929+
Self::NAN // log(-n) = NaN
938930
}
931+
} else if self.is_nan() {
932+
self // log(NaN) = NaN
933+
} else if self > 0.0 {
934+
self // log(Inf) = Inf
935+
} else {
936+
Self::NAN // log(-Inf) = NaN
939937
}
940938
}
941939
}

0 commit comments

Comments
 (0)