Profile and optimize

- Eliminate unnecessary copies of grammar objects
- Do cheaper comparisons first in equality methods
Reduce allocations when computing rule transitions