Checking if a pointer is NULL, is this fast?

Checking if a pointer is NULL like this, is this fast? If it is done every frame, many times….

e.i.

void SomeFunction(MyClass* myClass)
{
     //Check to see if the pointer is NULL.  If so, do nothing
     //Is this fast enough to do often or is heavy on performance?
     if(myClass == NULL)
          return;

      //If not NULL, do something
      myClass->DoSomeOtherFunction();
}

also, is there a difference between the top one these other two ways to do it? Which one of the three is best?

if(myClass)
{
     myClass->DoSomething();
}

//AND

if(!myClass)
     return;

myClass->DoSomething();

I bet this code will be compliled in the same assembler instructions. Pointer is usually fit to integer size, and most CPUs have very quick check for zero integer value.
In short: all of your code should be fine. That’s not the thing you should worry about.

NULL is zero, and when the pointer zero , it also means false, all of them are the same in fact:)

You can check out the assembler instructions.
I think

if(myClass)
{
     myClass->DoSomething();
}

//AND

if(!myClass)
     return;

myClass->DoSomething();

are faster if the compiler don’t optimize the code of

void SomeFunction(MyClass* myClass)
{
     //Check to see if the pointer is NULL.  If so, do nothing
     //Is this fast enough to do often or is heavy on performance?
     if(myClass == NULL)
          return;

      //If not NULL, do something
      myClass->DoSomeOtherFunction();
}

Awesome. Thanks alot guys

Makes sense to me.