Skip to main content
Jon Chambers
Inspiring
November 13, 2016
Answered

Does "== true" slow down the final project?

  • November 13, 2016
  • 2 replies
  • 527 views

I know it's nothing in the scheme of things, but anywhere with the expression "== true", that segment of code can be deleted and the program will be executed exactly the same. Does this mean that the program is running slightly slower, because it needs to return true if true? Or is the compiler smarter than that, and ignores "== true" treating it as a comment? I like having "== true" in my project because they help me remember I'm working with a Boolean value, but I will delete them if there is the smallest chance of a slight performance gain.

This topic has been closed for replies.
Correct answer kglad

on my computer using fp 24, the first is faster by about 4/10000000 milliseconds.  ie, not very much difference.

2 replies

Jon Chambers
Inspiring
November 26, 2016

Good tip on the "is". I'm just working on this project by myself, so it's not worth the effort of adding it to everything, but I will keep that in mind in future, especially if I ever get accepted onto a team, or have to include a variable in an API.

kglad
Community Expert
Community Expert
November 13, 2016

copy and paste a sample of the line of code you want to test.

Jon Chambers
Inspiring
November 13, 2016

Typing from my phone, so forgive me if I make a syntax error:

if(true)

{

trace('How fast was that?')

}

vs.

if(true == true)

{

trace('How fast was that?')

}

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 13, 2016

on my computer using fp 24, the first is faster by about 4/10000000 milliseconds.  ie, not very much difference.