Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor duplicate code out of parsers #976

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

notriddle
Copy link
Collaborator

@notriddle notriddle commented Oct 29, 2024

This PR has miscellaneous refactoring, to reduce duplicate source code and generated code size:

  • It introduces a couple helper functions, skip_container_prefixes and scan_next_line_or_lazy_continuation, to reduce code duplication.
  • It passes Options itself down instead of bool, to prevent some potentially very easy mixups.
  • It lifts some bound checked slices outside the loop, particularly in cases where I checked (using cargo-show-asm) that the compiler couldn't see it.

Verified

This commit was signed with the committer’s verified signature.
eramongodb Ezra Chung
This reduces the number of bounds checks, bringing instruction
count down from about 1600 to 1400.
This reduces the number of bounds checks, reducing the number
of lines of assembly from about 1100 to 900.
@notriddle notriddle force-pushed the notriddle/cleanup branch 2 times, most recently from 5a13ac8 to f2aa1e8 Compare October 29, 2024 00:10
This reduces duplicate code, bringing parse_block down from
9073 to 8617, ignoring parse_footnote_definition, which
didn't used to be inlined but now is.
@Martin1887 Martin1887 merged commit a51be4f into pulldown-cmark:master Oct 29, 2024
6 checks passed
@Martin1887
Copy link
Collaborator

Thanks!

@notriddle notriddle deleted the notriddle/cleanup branch October 29, 2024 15:25
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.

None yet

2 participants