-
-
Notifications
You must be signed in to change notification settings - Fork 226
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
Bad perf case: Lots of delimiters that can close but no openers #43
Comments
When they have no matching openers and cannot be openers themselves, we can safely remove them. This helps with a performance case: "a_ " * 20000. See commonmark/commonmark.js#43.
Thanks for bringing this to my attention. Your proposed Still TODO: implement in commonmark.js. This should |
Tests for many emph closers without matching openers, openers without matching closers, and similarly for links. See #43.
Thanks 👍. Just found another case that's related: |
And another case is this: |
I have now fixed all of these problems in cmark. TODO: commonmark.js. |
add README for chance
When they have no matching openers and cannot be openers themselves, we can safely remove them. This helps with a performance case: "a_ " * 20000. See commonmark/commonmark.js#43.
The test input is
a_
(a, underscore, space) repeated 20000 times. The problem seems to be that inprocessEmphasis
, for each potential closer, the opener is searched all the way back to the stack bottom.Maybe it could be improved by removing a closer after not finding a corresponding opener iff the closer can not be an opener, so as to not have to check it again. Not sure if this is correct in all cases though or if there are other worst case inputs (need to think about it more).
The text was updated successfully, but these errors were encountered: