Another way to speed things up would be to compare the *squared* values only in your collision detection test, and then work out the square root afterwards (only if a collision happens).
...