On Sun, Feb 12, 2012 at 6:45 AM, Aaron Patterson
<[email protected]>wrote:

Interesting.  Have you investigated expanding the regular expressions
> and doing hash based replacement via gsub!?  Since we can know the
> replacements in advance, it's possible to compile a hash and use it for
> the replacement.  If the hash misses, we can fall back to a linear scan.
>
> Here's a quick implementation as an example.  We could probably optimize
> more of the expressions:
>
>  https://gist.github.com/1806575


Interesting!

I think that approach does not guarantee the order though. Let's imagine
two inflection rules r1, r2. Let's take a word that matches both, and let's
suppose only r2 is precompilable. If I understand that alternative
correctly the algorithm would yield the replacement for r2, rather than r1.
True?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to