File tree 1 file changed +2
-2
lines changed
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -15504,14 +15504,14 @@ <h3>Example</h3>
15504
15504
<p>Checks for bit masks that can be replaced by a call
15505
15505
to <code>trailing_zeros</code></p>
15506
15506
<h3>Why is this bad?</h3>
15507
- <p><code>x.trailing_zeros() > 4</code> is much clearer than <code>x & 15 == 0</code></p>
15507
+ <p><code>x.trailing_zeros() >= 4</code> is much clearer than <code>x & 15 == 0</code></p>
15508
15508
<h3>Known problems</h3>
15509
15509
<p>llvm generates better code for <code>x & 15 == 0</code> on x86</p>
15510
15510
<h3>Example</h3>
15511
15511
<pre><code class="language-rust">if x & 0b1111 == 0 { }
15512
15512
</code></pre>
15513
15513
<p>Use instead:</p>
15514
- <pre><code class="language-rust">if x.trailing_zeros() > 4 { }
15514
+ <pre><code class="language-rust">if x.trailing_zeros() >= 4 { }
15515
15515
</code></pre>
15516
15516
<h3>Configuration</h3>
15517
15517
<ul>
You can’t perform that action at this time.
0 commit comments