Speed up go implementation by short-circuting suboptimal distance calculations early