Skip to content
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

Fix quadratic behavior when processing emphasis #390

Merged
merged 2 commits into from
Jul 16, 2021

Conversation

nwellnhof
Copy link
Contributor

Fixes #388 and #389.

Make sure to remove matching smart quote delimiters. Otherwise, the
same opener could be found over and over again, preventing the
`openers_bottom` optimization from kicking in and leading to quadratic
behavior when processing lots of quotes.

Fixes commonmark#388.
@nwellnhof nwellnhof force-pushed the quadratic-emphasis branch 2 times, most recently from 9f879e9 to b928047 Compare July 13, 2021 16:33
Delimiters can be deleted, so store delimiter positions instead of
pointers in `openers_bottom`. Besides causing undefined behavior when
reading a dangling pointer, this could also result in quadratic
behavior when parsing emphasis.

Fixes commonmark#389.
@jgm jgm merged commit ed0a4bf into commonmark:master Jul 16, 2021
@jgm
Copy link
Member

jgm commented Jul 16, 2021

Excellent fix!

@nwellnhof nwellnhof deleted the quadratic-emphasis branch September 24, 2021 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quadratic behavior when parsing smart quotes
2 participants