Skip to content

Commit 535efa4

Browse files
committed
Used copysign to avoid unnecessary branches.
1 parent 64e3a10 commit 535efa4

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

src/libstd/f32.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -910,15 +910,7 @@ impl f32 {
910910
pub fn asinh(self) -> f32 {
911911
match self {
912912
x if x == NEG_INFINITY => NEG_INFINITY,
913-
x if x.is_sign_negative() => {
914-
let v = (x + ((x * x) + 1.0).sqrt()).ln();
915-
if v.is_sign_negative() {
916-
v
917-
} else {
918-
-v
919-
}
920-
}
921-
x => (x + ((x * x) + 1.0).sqrt()).ln()
913+
x => (x + ((x * x) + 1.0).sqrt()).ln().copysign(self)
922914
}
923915
}
924916

src/libstd/f64.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -833,15 +833,7 @@ impl f64 {
833833
pub fn asinh(self) -> f64 {
834834
match self {
835835
x if x == NEG_INFINITY => NEG_INFINITY,
836-
x if x.is_sign_negative() => {
837-
let v = (x + ((x * x) + 1.0).sqrt()).ln();
838-
if v.is_sign_negative() {
839-
v
840-
} else {
841-
-v
842-
}
843-
}
844-
x => (x + ((x * x) + 1.0).sqrt()).ln()
836+
x => (x + ((x * x) + 1.0).sqrt()).ln().copysign(self)
845837
}
846838
}
847839

0 commit comments

Comments
 (0)