athurston/ragel — pull request #1 by YorickPeterse (2014-03-22 12:39:36+00:00)
Title: Ruby: reduce the amount of calls to GET_WIDE_KEY()

When using Ruby as the output GET_WIDE_KEY() would result in the following code
being generated:

data[p].ord

In Ruby string indexing/slicing (using String#[]) is not very efficient,
especially not when called a lot of times. In the cases where these changes
have been made multiple calls to String#[] were made where only 1 would be
needed.

The result of this is a noticable performance boost on machines that consume
large amounts of input. Smaller machines most likely won't notice a big
difference.

As an example: a XML/HTML lexer I'm working on using Ragel (at least for now)
would take 10 seconds or so to lex an input document using Ragel 6.7. Using
this patch that would be reduced to around 5-6 seconds [1].

Note that this patch only affects Ragel output generated with the -F1 option,
-T1 and -F0 remain unmodified.

[1]: using MRI 2.1.1