Modern compilers optimize those if-else chain as switch first.
Yes, when optimization is enabled they do (at least llvm-gcc 4.2 with -O3 does)
this is more for the DRY part and code readability.
Thanks for accepting patch.
|
nobu |
* compile.c (iseq_specialized_instruction): DRY and replace chain
…
of if-else with switch for special instructions. based on a patch by Vasfed. ruby#105 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e |
0d1c226
|
|
nobu |
* compile.c (iseq_specialized_instruction): DRY and replace chain
…
of if-else with switch for special instructions. based on a patch by Vasfed. ruby#105 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e |
bd08b29
|
DRY and replace chain of if-else (O(n)) with switch (O(1)) for specia… …
…l instructions
Remove result of copy-pasting with preprocessor macro and replace chain of else-if with switch statement.
(if-else is O(n), switch is O(1) )