You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanclass="hljs-comment">// Approximate using bit operations (no division!)</span>
975
976
<spanclass="hljs-type">int</span> y = (<spanclass="hljs-number">19</span> * <spanclass="hljs-built_in">int_log2</span>(x) >> <spanclass="hljs-number">6</span>);
976
977
@@ -980,14 +981,11 @@ <h1 id="optimization-3-fast-digit-counting">Optimization #3: Fast Digit Counting
980
981
981
982
<spanclass="hljs-keyword">return</span> y + <spanclass="hljs-number">1</span>;
982
983
}
983
-
984
-
Zero allocations, no string conversion, just math!
985
-
986
-
# Optimizations #<spanclass="hljs-number">4</span> & #<spanclass="hljs-number">5</span>: Branch Hints & Buffer Growth
987
-
988
-
**Branch Prediction:**
989
-
```<spanclass="hljs-function">cpp
990
-
<spanclass="hljs-title">if</span><spanclass="hljs-params">(UNLIKELY(buffer_full))</span></span>{ <spanclass="hljs-comment">// CPU knows this is rare</span>
984
+
</code></pre>
985
+
<p>Zero allocations, no string conversion, just math!</p>
986
+
<h1id="optimizations-4--5-branch-hints--buffer-growth">Optimizations #4 & #5: Branch Hints & Buffer Growth</h1>
987
+
<p><strong>Branch Prediction:</strong></p>
988
+
<preis="marp-pre" data-auto-scaling="downscale-only"><codeclass="language-cpp"><spanclass="hljs-keyword">if</span> (<spanclass="hljs-built_in">UNLIKELY</span>(buffer_full)) { <spanclass="hljs-comment">// CPU knows this is rare</span>
991
989
<spanclass="hljs-built_in">grow_buffer</span>();
992
990
}
993
991
<spanclass="hljs-comment">// CPU optimizes for this path</span>
0 commit comments