mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Markdown.ToHtml takes more than two minutes to complete when processing the 32K file #273
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Metalnem on GitHub (Feb 9, 2019).
Markdown.ToHtml takes more than two minutes to complete when processing the 32K file from the attached archive. You can reproduce this by running the following program and passing it the path to the extracted file as a command line argument:
I'm using Markdig 0.15.7 and .NET Core 2.2.103.
Found via SharpFuzz.
@MihaZupan commented on GitHub (Feb 9, 2019):
This does not appear to be an issue on the master branch. There is a slight difference in output
https://gist.github.com/MihaZupan/a5ce072fffec28315cbdcfd779b203e9/revisions#diff-20e4e18dfae3d1b38df3bce24863b74dR3
See the end of the huge block
@MihaZupan commented on GitHub (Feb 9, 2019):
I believe this was addressed by the changes to the Abbreviation parser.
On 15.7, this loop seems to iterate over every character
EDIT:
Said loop iterates over each character in both versions, the master branch is just faster becuase of this check.
Basically, both versions, for each character loop over the remainer of the string => O(n^2), but the 15.7 version does a TextMatcher.TryMatch call for each of those inner iterations.
@Metalnem commented on GitHub (Feb 9, 2019):
You are right, the master works fine. Do you want me to close this issue, or is there something that can be done about the O(n^2) complexity?