Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce allocs by making SmartConstructors stateful
Summary: Major refactoring of the parser in hope of squeezing noticeable gains by not passing around SmartConstructors state. Basically, replace the following: make_XYZ(state: State, ...) -> (State, R) with make_XYZ(&mut self, ...) -> R and make each of the 5 implementors of SmartConstructors stateful by turning the old method `initial_state(...)` into constructor `new`. Unfortunately, this means more boilerplate in the **user code** (i.e., implementors of SmartConstructors): - implementing Clone for each implementor of StateType - implementing Clone for each implementor of SmartConstructors this *cannot* be auto-generated via `#[derive(Clone)` because of the [`PhantomData`](rust-lang/rust#29005 (comment)) that is needed to narrow down trait impl of `StateType`. Reviewed By: shiqicao Differential Revision: D16374645 fbshipit-source-id: 37c248e70d93dd505e5478a57b646ad469907d7c
- Loading branch information