[performance] improve collision detection loops