How to avoid unnecessary if statements every update based on boolean value that does not change after being set

Viewed 110

If I have the following:

bool type;

int main();
{
        type = false;
}


void update()
{
        if( type == false )
        {
                //do something
        }
        else
        {
                //do something else
        }

}

The code will set the value of type to either true or false, using an if statement will cause the compiler to check what the value is every update, I want to avoid this and only do one check since the type will be set and then not changed. Is there some way to make it only check once?

0 Answers
Related