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

Change-Id: If1c91f3bc1e785434f153c5bc0d14befbc75e6cb