Make Linear.__hash__ more efficient

This seems to speed things up by 2.5x for BDD, so that's good.