Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    yaserifti1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    The finest pussies of Earth
    Posts
    250
    Reputation
    9
    Thanks
    10
    My Mood
    Angelic

    switch vs if-else

    uhm... which one would be better to use for a menu hack?
    BTW these are random examples I made up...
    switch -

    Code:
    switch (x) {
      case 1:
        cout << "x is x";
        break;
      case 2:
        cout << "x is xx";
        break;
      default:
        cout << "value of x unknown";
      }
    if-else -
    Code:
    if (x == 1) {
      cout << "x is 1";
      }
    else if (x == 2) {
      cout << "x is 2";
      }
    else {
      cout << "value of x unknown";
      }
    YES I KNOW THEY ARE EQUIVALENT, BUT WHICH IS MORE EFFICIENT?
    Key:
    = done
    = not done
    = working on it
    = damn I killed it!

    Accomplishments On MPGH:

    make a mod -

    make a gun to gun mod -

    make a hack -

    learn C++ -

    roast a nub -

  2. #2
    wicho_koz's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    193
    Reputation
    12
    Thanks
    52
    My Mood
    Shocked
    if i like (If)

  3. #3
    yaserifti1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    The finest pussies of Earth
    Posts
    250
    Reputation
    9
    Thanks
    10
    My Mood
    Angelic
    yeah, me too, but which is more efficient?
    Key:
    = done
    = not done
    = working on it
    = damn I killed it!

    Accomplishments On MPGH:

    make a mod -

    make a gun to gun mod -

    make a hack -

    learn C++ -

    roast a nub -

  4. #4
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Switch is faster...

  5. #5
    yaserifti1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    The finest pussies of Earth
    Posts
    250
    Reputation
    9
    Thanks
    10
    My Mood
    Angelic
    k thx bai!
    Key:
    = done
    = not done
    = working on it
    = damn I killed it!

    Accomplishments On MPGH:

    make a mod -

    make a gun to gun mod -

    make a hack -

    learn C++ -

    roast a nub -

  6. #6
    why06jz's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    295
    Reputation
    14
    Thanks
    54
    you do understand the efficiency difference is so negligible that if you don't even know C++ the chances you''l be able to use it effectively are very slim and even if you did, it's quite pointless. Use whatever makes sense. Don't make nonsensical error-prone code to scrape out 1ms of a difference, your much more likely to cause memory leaks or repeatedly create large data structures on the stack instead of just accepting them as a parameter or global variable and other errors doing that and then that 1ms difference is pointless.

  7. #7
    GodHack2's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    644
    Reputation
    38
    Thanks
    762
    My Mood
    Amused
    wrong section buddy





    beat this bitches ^^^^^^^

    Current Stats : Bored :/


    Respect list :
    Crash !
    Gordon'
    Markoj

  8. #8
    _Fk127_'s Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    720
    Reputation
    16
    Thanks
    208
    My Mood
    Bitchy
    This is a "Hack Coding" section. You are asking a programming question. They are two different things. Well not to you . But yeah wrong section



    Put this image in your signature if you support HTML5 development!

  9. #9
    wicho_koz's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    193
    Reputation
    12
    Thanks
    52
    My Mood
    Shocked
    [IF] is more good for me!!

  10. #10
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    What why06jz said, He is right use the function that is suited to project and make sense.

  11. #11
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    5,052
    My Mood
    Cool
    Quote Originally Posted by why06jz View Post
    you do understand the efficiency difference is so negligible that if you don't even know C++ the chances you''l be able to use it effectively are very slim and even if you did, it's quite pointless. Use whatever makes sense. Don't make nonsensical error-prone code to scrape out 1ms of a difference, your much more likely to cause memory leaks or repeatedly create large data structures on the stack instead of just accepting them as a parameter or global variable and other errors doing that and then that 1ms difference is pointless.
    In case he does not make memory leaks large data structures and stuff.

    Did you try adding "Sleep(1);" inside of "Present", "BeginScene" or "EndScene" the difference is VERY LARGE.
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  12. #12
    yaserifti1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    The finest pussies of Earth
    Posts
    250
    Reputation
    9
    Thanks
    10
    My Mood
    Angelic
    Quote Originally Posted by why06jz View Post
    you do understand the efficiency difference is so negligible that if you don't even know C++ the chances you''l be able to use it effectively are very slim and even if you did, it's quite pointless. Use whatever makes sense. Don't make nonsensical error-prone code to scrape out 1ms of a difference, your much more likely to cause memory leaks or repeatedly create large data structures on the stack instead of just accepting them as a parameter or global variable and other errors doing that and then that 1ms difference is pointless.
    Thanks, I actually read all of dat...

    Quote Originally Posted by GodHack2 View Post
    wrong section buddy
    K sorry, didn't know.

    Quote Originally Posted by _Fk127_ View Post
    This is a "Hack Coding" section. You are asking a programming question. They are two different things. Well not to you . But yeah wrong section
    Yeah, realise that now

    Ah, thanks blast.
    Key:
    = done
    = not done
    = working on it
    = damn I killed it!

    Accomplishments On MPGH:

    make a mod -

    make a gun to gun mod -

    make a hack -

    learn C++ -

    roast a nub -

  13. #13
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Switch allows you to fall through, if doesn't. That's about the only difference.

    switch (crosshairType)
    (
    Case 3: // vertical + horiztaonl
    // vertical
    Case 2:
    // horzintal
    break;
    Case 1: // vertical
    //vertical
    }

    Typed on phone, sorry about the crap example.. I would have gown you a real code snippet of mine but yeah.

    Quote Originally Posted by topblast View Post


    In case he does not make memory leaks large data structures and stuff.

    Did you try adding "Sleep(1);" inside of "Present", "BeginScene" or "EndScene" the difference is VERY LARGE.
    --" irrelevant. And sleeping DOES NOT stop memory leaks, only cleaning up after your shit does.

  14. #14
    why06jz's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    295
    Reputation
    14
    Thanks
    54
    Adding Sleep inside of any D3D function hook might single handedly lag your hack to the point of being unusable.

  15. #15
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    I would only use switch statement when making a speed hack or some of the sort that has different speed/Values but other then that if statemant

Page 1 of 2 12 LastLast