Closed
Description
Detect usage of
if a < 0.0 { // or a.is_sign_negative()
-a
} else {
a
}
and
if a > 0.0 { // or a.is_sign_positive()
a
} else {
-a
}
and suggest usage of abs
instead
a.abs()
Using abs
is more efficient, handles more cases and is more succinct than using the if/else block so this lint could go under the suboptimal_flops
lint. If this seems like an obvious thing and isn't worth the check then I'd be happy to close it.