I suggest you to benchmark it. Is the overhead of the instanceof check bigger than the overhead of a function call to return true ?