Take advantage of if statement lazy evaluation

Directly compare types which will be much faster for value types, then fall back to checking with Equals.