[automerger] Optimise the hit test algorithm am: 71ecf5bd5c am: 42eaa8f932

Change-Id: I2ac44759ff615b32724f5235d3e5e8dc8c9b4ced