Skip to content

Parse block tags glued to an HTML tag name in linear time in liquid-parser - #1406

Merged
charlespwd merged 1 commit into
mainfrom
osdp-37-rust-linear-glued-blocks
Nov 18, 2026
Merged

charlespwd merged 1 commit into
mainfrom
osdp-37-rust-linear-glued-blocks

Conversation

@lucyxiang

Copy link
Copy Markdown
Contributor

A Liquid block tag glued to an HTML tag name, such as <a{% if x %}{% endif %}>, makes liquid-parser look ahead. An empty block body renders nothing, so each such block read to the end of the HTML tag. The parse time grew with the square of the number of blocks. The check for an output segment also read the whole name again for each glued tag.

This PR keeps the last look-ahead of each name and reuses it for a block that the last look-ahead read past. The name also records its segment kinds as they arrive. The parsed trees do not change.

  • cargo test -p liquid-parser --locked: 13 passed.

@lucyxiang
lucyxiang marked this pull request as ready for review November 18, 2026 16:07
@lucyxiang
lucyxiang requested a review from a team as a code owner November 18, 2026 16:07
@lucyxiang
lucyxiang requested a review from charlespwd November 18, 2026 16:07
@charlespwd
charlespwd merged commit ede4d4f into main Nov 18, 2026
9 checks passed
@charlespwd
charlespwd deleted the osdp-37-rust-linear-glued-blocks branch November 18, 2026 16:16
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

Successfully merging this pull request may close these issues.

2 participants