Optimize goal changed

Make goal changed approximately O(paths + targets), instead of something much worse.

Testing Done:
Correctness: https://travis-ci.org/pantsbuild/pants/builds/43764453

Performance: tested on a megachange branch on Twitter's monorepo; previous time was on the order of hours; time with patch is 3 minutes.

Reviewed at https://rbcommons.com/s/twitter/r/1470/
Make zinc relative its -classpath argument too.