Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1b1
-
Fix Version/s: JRuby 1.0.3, JRuby 1.1RC2
-
Component/s: Compiler, Core Classes/Modules, Parser
-
Labels:None
-
Environment:Anywhere
-
Testcase included:yes
-
Number of attachments :
Description
Ruby regular expressions provide a /o option with the following meaning (from Pickaxe, forgive me):
o - Substitute Once.
Any #... substitutions in a particular regular expression literal will be performed just once, the first time it is evaluated. Otherwise, the substitutions will be performed every time the literal generates a Regexp object.
JRuby currently ignores the modifier, which results in lower performance when a library is counting on the feature. For example, CodeRay (http://coderay.rubyforge.org/) uses it heavily, and runs about 10,000 times slower with jruby 1.1b1.
Testing the feature is simple:
{{assert Array('a'..'z').map { |c| c.to_s/#{c}/o }.compact.size == 1}}
This shouldn't be hard to fix for 1.1 and 1.0.3 (easy backport for the 1.0 interpreter).