perf: optimize reference link masking - #4048
Open
sarthakagrawal927 wants to merge 2 commits into
Open
Conversation
|
@sarthakagrawal927 is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
sarthakagrawal927
marked this pull request as ready for review
August 9, 2026 05:23
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
UziTech
reviewed
Aug 10, 2026
UziTech
requested changes
Aug 11, 2026
| let maskedSrc = src; | ||
|
|
||
| // Mask out reflinks | ||
| if (this.tokens.links) { |
Member
There was a problem hiding this comment.
We should still check if (this.tokens.links && Object.entries(this.tokens.links).length > 0) to prevent checking if we don't need to
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Marked version: 681373c
Markdown flavor: n/a
Description
Reference-link masking rebuilt
Object.keys(this.tokens.links)for everyqueued inline source, then linearly searched it for every candidate. At 2,000
definitions and paragraphs, that is about four million temporary key entries
and two million string comparisons.
This checks the existing table with
Object.hasOwn, removing both costs withoutadding lexer state or changing output.
Performance
Thirty alternating fresh-process pairs on Node.js 26.7.0, with per-process
warmup. Values are medians; intervals are paired 95% bootstrap intervals.
A 2,000-paragraph no-definition control moved +1.3% (+0.3, +2.3). Guards that
avoid that scan also re-enumerated the link table and erased most of the target
gain, so this keeps the smaller implementation and scopes the claim.
Validation
npm testContributor
the unchanged parsing behavior.
feature.
Committer