Search code examples
performanceprogramming-languagesevaluation

!= false vs. == true


I think I've read somewhere that the evaluation of negation (!= false) is faster than == true

Is this correct?


Solution

  • That's not correct. All modern compilers and interpreters will optimize that.

    What matters (to me, at least) is that == true is much faster for ME to interpret.

    Remember, premature optimization is the root of all evil.

    Edit: Yes, i use if(true). But that was not the question.