Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Morpheus and IF

  1. #11

    Default

    Can't believe I missed a set of brackets.

    I did figure out using a waitframe if it looked like I'd drop straight through a loops.

    Generally I use switches if the context will require more than 3 if/else/whatever. Is there a certain point where switches will not show any improvement or is it just always better to use?

  2. #12
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    276

    Default

    Don't beat yourself up. I forget far more than just brackets every day.....

    Generally, in other languages, it is more efficient to interpret a case statement, or emit a jump table for one, than evaluate or emit code for a corresponding set of 'if' constructs, virtually regardless of the number of conditions since a switch only has one condition to evaluate. Simply put, I cant imagine a scenario where multiple comparisons against a constant wouldn't be less expensive than a full blown eval of an expression multiple times.

    I do not know how Morpheus specifically handles this, but I'd be very surprised if it was different. My statement should not be taken as authoritative but it is likely to be true Someday when I find some 'roundtuits', or someone else familiar with it, will look.

    Tode
    Last edited by Todesengel; November 16th, 2019 at 11:40 AM. Reason: 4:20

  3. #13

    Default

    Appreciate your input

    Maybe I can do some test case comparisons for speed.

    I tend to use multiple comparatives or ranges within my IF statements which tend to not translate well into a switch. But hey, where there is a will there is a way!

Posting Permissions

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