-
Notifications
You must be signed in to change notification settings - Fork 11
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
Allow rendering borrowed events #29
Conversation
e75f12e
to
abeed56
Compare
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.
Left some notes.
Re. the performance degradation: You should still be able to go back to the old way, right (footnote_backlink_written
,) or is there something in this new trait that makes it unfeasible? Might be worth trying, and seeing if we gain back that performance loss.
Previously, we relied on the fact that we could peek ahead and check if the upcoming event was a End(Footnote). But now, we instead take one event at a time instead of the whole iterator, so we can't know what will come next. I guess it would still be possible to override the push/push_ref functions and add that functionality there. Or maybe there is something smarter we can do |
Try to make rendering of each event independent. The only case where we need to peek is when a backref link should be added to the last paragraph within a footnote. Before, when exiting a paragraph, we would peek and add the link before emitting the close tag if the next event is a the footnote end. Now, the paragraph end event skips emitting a paragraph close tag if it is within a footnote. The next event will then always close the paragraph, and if it is a footnote end, it will add the backref link before closing.
no longer useful as no peeking is needed, use simple early exit instead
separate input/output from rendering state
They apply more to the Render trait now than the implementation in the html module
tried a benchmark just to make sure there is a noticeable benefit to borrowing instead of cloning:
compared to master:
so, we are 15% faster for borrowed events but 4% slower for owned events.. |
derive push/write automatically from these
allow rendering iterators with borrowed events resolves #24
allow comparing between rendering owned, borrowed or cloned events
Merge branch 'render_ref' closes #29
addressing #24
benchmarks
both criterion and iai seem to agree there is some loss in performance. note that iai is parse + render and criterion is just the html rendering.
it seems like the avoid peek commit is the biggest problem. I'm not entirely sure why but I guess it is because we add some checks in the render loop:
maybe there is a better way to do it?