PERF: Rewrite assign_candidates() for speed.