mirror of
https://github.com/gomson/TimothyLottes.github.io.git
synced 2026-11-17 11:30:08 -08:00
Add files via upload
This commit is contained in:
1 parent
85320961f1
commit
2e415e7239
3 files changed
+23
-1
No files matched your search
@@ -0,0 +1,10 @@
|
||||
<html><head><link rel="stylesheet" href="style.css"></head><body><div class="page">
|
||||
<h1>20101004 - MSVC Optimizing Static Constant Function Tables?</h1>
|
||||
<br>
|
||||
|
||||
|
||||
Nope. Would be nice if the MSVC compiler could optimize FunctionJump() like FunctionIf() below,<br /><br /><!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #8f5902; font-style: italic">#include <stdio.h></span><br /><br /><span style="color: #204a87; font-weight: bold">typedef</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000; font-weight: bold">(</span><span style="color: #ce5c00; font-weight: bold">*</span><span style="color: #000000">Function</span><span style="color: #000000; font-weight: bold">)(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span><span style="color: #000000; font-weight: bold">);</span><br /><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">FunctionA</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">)</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #000000">printf</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #4e9a06">"a=%d\n"</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">);</span> <span style="color: #000000; font-weight: bold">}</span><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">FunctionB</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">)</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #000000">printf</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #4e9a06">"b=%d\n"</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">);</span> <span style="color: #000000; font-weight: bold">}</span><br /><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">const</span> <span style="color: #000000">Function</span> <span style="color: #000000">function</span><span style="color: #000000; font-weight: bold">[</span><span style="color: #0000cf; font-weight: bold">2</span><span style="color: #000000; font-weight: bold">]</span> <span style="color: #ce5c00; font-weight: bold">=</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #000000">FunctionA</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #000000">FunctionB</span> <span style="color: #000000; font-weight: bold">};</span><br /> <br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">FunctionJump</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">)</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #000000">function</span><span style="color: #000000; font-weight: bold">[</span><span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">](</span><span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">);</span> <span style="color: #000000; font-weight: bold">}</span><br /><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">FunctionIf</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">)</sLine truncated
|
||||
|
||||
</div></body></html>
|
||||
|
||||
|
||||
Reference in new issue
Block a user