Skip to content
  • Yusuke Endoh's avatar
    0a0760aa
    Refactor and improve performance of RDoc::Markup::Parser · 0a0760aa
    Yusuke Endoh authored
    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.
    0a0760aa
    Refactor and improve performance of RDoc::Markup::Parser
    Yusuke Endoh authored
    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.
Loading