-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed RefCells for dispatcher. #220
Removed RefCells for dispatcher. #220
Conversation
a90a9e9
to
068d90c
Compare
src/parser/state_machine/mod.rs
Outdated
|
||
fn enter_cdata(&mut self, input: &[u8]); | ||
fn leave_cdata(&mut self, input: &[u8]); | ||
type PassingState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking for a better name for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's overused as a term, but Context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that's good: it is generic, but the nature of this type is also generic!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, was about to write that it's better to use ParserContext
. Also, drop passing
and shared
prefixes. Just pass ctx: ParserContext
around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't have a time to do a deep dive in the code, so it's easier to just ask here: why it needs to be a type parameter? is it because the state is generic over S
. Can we just make StateMachine
trait generic then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it needs to be a type parameter? is it because the state is generic over S.
It's because we need to reference it in the trait methods. (The ones in directly in the trait and the ones added by macros on the StateMachine
"sub"-trait).
Can we just make StateMachine trait generic then?
Not sure if I understand: the traits are generic over the context.
068d90c
to
ee4b343
Compare
We now explicitly pass that state around. This will reduce the number of `Mutex`es in a `Send` version of the rewriter.
ee4b343
to
efd8398
Compare
We now explicitly pass that state around. This will reduce the number of
Mutex
es in aSend
version of the rewriter.Benchmarks show a median speedup of 0.4%... so, no performance difference when all benchmarks are aggregated.