Yes.  I have a piece of code that looks a lot like this function, and this was an optimization I used there as well.