|
|
|
[
Permlink
| « Hide
]
Charles Oliver Nutter - 11/Nov/07 01:45 AM
This shouldn't be hard to fix for 1.1 and 1.0.3 (easy backport for the 1.0 interpreter).
Initial patch for compiler off mode.
Tested with: jruby -C -e "10.times {|i| puts i.to_s/#{i}/o }" Should now return: 0 btw, patch for 1.1
Pretty much do the same thing as done to ASTInterpreter to EvaluationState in 1.0 (I don't have the source handy) This alters the compiler to achieve the same end.
It lends from the optimisation in the ByteList processing RegExp which checks to see if it had already created a RegExp from the same ByteList. In this alteration, we check to see if the source specified the /o flag. If it did, we store the first evaluation and then jump on subsequent evaluations, so the closure is, in effect, only evaluated once at runtime. And an extra testRegexp.rb minirunit test to check behaviour (with and without /o flag)
Patches look good, thanks Josh! Fixed on trunk in 4952 and on 1.0 branch in 4953.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||