mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
perf(manual_is_power_of_two): perform the is_integer_literal check first
.. as it's much cheaper than `count_ones_receiver`
This commit is contained in:
@@ -70,12 +70,12 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'tcx>) {
|
||||
if !expr.span.from_expansion()
|
||||
&& let Some((lhs, rhs)) = unexpanded_binop_operands(expr, BinOpKind::Eq)
|
||||
{
|
||||
if let Some(a) = count_ones_receiver(cx, lhs)
|
||||
&& is_integer_literal(rhs, 1)
|
||||
if is_integer_literal(rhs, 1)
|
||||
&& let Some(a) = count_ones_receiver(cx, lhs)
|
||||
{
|
||||
self.build_sugg(cx, expr, a);
|
||||
} else if let Some(a) = count_ones_receiver(cx, rhs)
|
||||
&& is_integer_literal(lhs, 1)
|
||||
} else if is_integer_literal(lhs, 1)
|
||||
&& let Some(a) = count_ones_receiver(cx, rhs)
|
||||
{
|
||||
self.build_sugg(cx, expr, a);
|
||||
} else if is_integer_literal(rhs, 0)
|
||||
|
||||
Reference in New Issue
Block a user