Skip to content

Commit

Permalink
md_is_inline_link_spec: Use md_lookup_line() instead of walking.
Browse files Browse the repository at this point in the history
Fixes #236.
  • Loading branch information
mity committed Feb 1, 2024
1 parent 729e6b8 commit f37a89f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
# MD4C Change Log


## Next Version (Work in Progress)

Fixes:

- [#236](https://github.com/mity/md4c/issues/236):
Fix quadratic time behavior caused by one-by-one walking over block lines
instead of calling `md_lookup_line()`.


## Version 0.5.2

Changes:
Expand Down
3 changes: 1 addition & 2 deletions src/md4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2332,8 +2332,7 @@ md_is_inline_link_spec(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines,
OFF off = beg;
int ret = FALSE;

while(off >= lines[line_index].end)
line_index++;
md_lookup_line(off, lines, n_lines, &line_index);

MD_ASSERT(CH(off) == _T('('));
off++;
Expand Down
5 changes: 4 additions & 1 deletion test/pathological-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@
"huge table":
(("th|" * 10000 + "\n" + "-|" * 10000 + "\n" + "td\n" * 10000),
re.compile(""),
"--ftables")
"--ftables"),
"many broken links":
(("]([\n" * 50000),
re.compile("<p>(\]\(\[\r?\n){49999}\]\(\[</p>"))
}

whitespace_re = re.compile('/s+/')
Expand Down

0 comments on commit f37a89f

Please sign in to comment.