Project

General

Profile

« Previous | Next » 

Revision 0a0760aa

Added by mame (Yusuke Endoh) over 4 years ago

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

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.