Get rid of some quadratic behavior #842
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
markdown-match-bold and markdown-match-italic both call markdown-inline-code-at-pos-p on each candidate match, which takes linear time in the distance
from the start of the block to the point being checked.
In a large block with many candidate matches inside inline blocks, this is slow because the function is called with each candidate, resulting in overall quadratic behavior, which this commit fixes by starting the code-at-pos scan after the last already-found match.
For example, the following benchmark code:
takes about 10.5 seconds before this commit, and about 0.14 seconds after this commit.
Description
Related Issue
Type of Change
Checklist
make test
).(except
test-markdown-export/buffer-local-css-path
which was already failing)