Repository navigation
Conversation
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Unused Dependencies ✔️
For details on how to fix these, see dependency_validator. This check can be disabled by tagging the PR with |
There was a problem hiding this comment.
Code Review
This pull request optimizes the inline parsing performance of the markdown parser to prevent quadratic time complexity on lines with many brackets or emphasis delimiters. It replaces the list-based delimiter stack and HTML node tree with custom linked list structures (_DelimiterNode and _TreeNode) and updates the parsing routines accordingly. A regression test is also added to verify the performance improvement. The reviewer suggested optimizing the StringBuffer initialization in _combineAdjacentText to avoid an intermediate string allocation.
| final buffer = StringBuffer( | ||
| '${node.textContent}${nodes[i + 1].textContent}', | ||
| ); |
There was a problem hiding this comment.
Using string interpolation inside the StringBuffer constructor creates an intermediate string before passing it to the buffer. Since this is a performance-focused PR, we can optimize this by initializing the StringBuffer with the first string and then writing the second string directly, avoiding the intermediate string allocation.
| final buffer = StringBuffer( | |
| '${node.textContent}${nodes[i + 1].textContent}', | |
| ); | |
| final buffer = StringBuffer(node.textContent) | |
| ..write(nodes[i + 1].textContent); |
b3ca705 to
c3ab156
Compare
c3ab156 to
2eaeb88
Compare
Replace
List-based AST/delimiter searches and removals inInlineParserwith doubly-linked lists (_TreeNode,_DelimiterNode) and a linked bracket stack (_topBracket), bound backward emphasis scans by a 6-slotopenersBottomtable, and compact adjacentTextnodes iteratively in place.