Skip to content

Refactor and improve performance of RDoc::Markup::Parser #730

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

Merged
merged 1 commit into from
Aug 14, 2019

Conversation

mame
Copy link
Member

@mame mame commented Aug 6, 2019

This change introduces a wrapper of StringScanner that is aware of the
current position (column and lineno).
It has two advantages: faster and more modular.

The old code frequently runs @input.byteslice(0, byte_offset).length
to get the current position, but it was painfully slow. This change
keeps track of the position at each scan, which reduces about half of
time of "Generating RI format into ..." in Ruby's make rdoc
(5.5 sec -> 3.0 sec).

And the old code used four instance variables (@input, @line,
@line_pos, and @s) to track the position. This change factors them
out into MyStringScanner, so now only one variable (@s) is needed.

This change introduces a wrapper of StringScanner that is aware of the
current position (column and lineno).
It has two advantages: faster and more modular.

The old code frequently runs `@input.byteslice(0, byte_offset).length`
to get the current position, but it was painfully slow.  This change
keeps track of the position at each scan, which reduces about half of
time of "Generating RI format into ..." in Ruby's `make rdoc`
(5.5 sec -> 3.0 sec).

And the old code used four instance variables (`@input`, `@line`,
`@line_pos`, and `@s`) to track the position.  This change factors them
out into MyStringScanner, so now only one variable (`@s`) is needed.
@aycabta aycabta merged commit fba8d45 into ruby:master Aug 14, 2019
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