Results 1 to 5 of 5

Thread: If Parser

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Well, I'm no expert on assembly and compiler writing, but if I were you, I would reduce the if statement to use just on je/jne.

    Basically your example is build like this:
    Code:
    if (( boolean or boolean ) or boolean or (boolean and boolean)) {
    ...
    }
    There is no need to test every boolean when you can combine them with logical operations in to one single boolean and then test if that boolean is true or false.
    Code:
    ( boolean or boolean ) or boolean or ( boolean and boolean)
    => boolean or boolean or boolean // 1st reduction
    => boolean // 2nd reduction
    This of course means that you are making a full evaluation of the if expression. If you want lazy evaluation you will only need to make the 1st reduction (sequentially as needed) and then test on each boolean.
    Last edited by pstudio; 08-03-2013 at 08:45 PM.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •