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

Parsing \\``\… takes quadratic time #736

Closed
andersk opened this issue Nov 23, 2020 · 1 comment
Closed

Parsing \\``\… takes quadratic time #736

andersk opened this issue Nov 23, 2020 · 1 comment

Comments

@andersk
Copy link

andersk commented Nov 23, 2020

(Thanks for your quick responses to these issues!)

Although #733 \``\``\``… was fixed:

$ time node -e 'require("markdown-it")().render("\\``".repeat(80000))'
0.08user 0.01system 0:00.09elapsed 111%CPU (0avgtext+0avgdata 43580maxresident)k
0inputs+0outputs (0major+4681minor)pagefaults 0swaps

changing the order to ``\``\``\… still takes quadratic time:

$ time node -e 'require("markdown-it")().render("``\\".repeat(10000))'
1.07user 0.00system 0:01.07elapsed 100%CPU (0avgtext+0avgdata 38260maxresident)k
0inputs+0outputs (0major+3423minor)pagefaults 0swaps
$ time node -e 'require("markdown-it")().render("``\\".repeat(20000))'
3.82user 0.01system 0:03.83elapsed 100%CPU (0avgtext+0avgdata 39680maxresident)k
0inputs+0outputs (0major+3701minor)pagefaults 0swaps
$ time node -e 'require("markdown-it")().render("``\\".repeat(40000))'
13.46user 0.01system 0:13.47elapsed 100%CPU (0avgtext+0avgdata 42328maxresident)k
0inputs+0outputs (0major+4944minor)pagefaults 0swaps
$ time node -e 'require("markdown-it")().render("``\\".repeat(80000))'
57.60user 0.02system 0:57.73elapsed 99%CPU (0avgtext+0avgdata 48068maxresident)k
0inputs+0outputs (0major+6850minor)pagefaults 0swaps
rlidwka added a commit that referenced this issue Nov 25, 2020
@rlidwka
Copy link
Member

rlidwka commented Nov 25, 2020

Fixed, thanks for reporting.

(due to small oversight, previous attempt at fixing this only worked if last character was a backtick)

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

No branches or pull requests

2 participants