Skip to content

Factor duplicate code out of parsers#976

Merged
Martin1887 merged 3 commits intopulldown-cmark:masterfrom
notriddle:notriddle/cleanup
Oct 29, 2024
Merged

Factor duplicate code out of parsers#976
Martin1887 merged 3 commits intopulldown-cmark:masterfrom
notriddle:notriddle/cleanup

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.

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
@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.

2 participants