Like everyone has said, it depends heavily on your particular situation. I'm going to mention an approach that you almost certainly should NOT use. If clarity is important, DO NOT DO THIS. But it's fun, so I'm going to try to write about it.

You can pack the variables into fewer variables.

Lets say you have two variables A and B. Each can have a value from 0 - 99. Then we could multiply Ax100 and add it to B. Then we have 1 variable instead of two but it contains all the information of the 2 original variables and you can check it easily in one operation.

To continue the example, Lets say if A=34 and B=75 the world explodes. All we have to do is our little operation and then see if it equals 3475.

This is the same thing you see with bit maps for things like file permission modes.

Again, this is NOT AT ALL recommended for clarity. It's just another way of thinking of a problem like this.

It's also probably not faster than a whole buncha == && == &&. I think it would depend on how many variables, how many iterations it goes through etc...


In reply to Re: Conditional Elimination by pileofrogs
in thread Conditional Elimination by dunnyman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.