Issue #3388 has been updated by Eregon (Benoit Daloze).


headius (Charles Nutter) wrote:
> JRuby currently does have a global cache for regexps. If you're interested, one of us can show you how it works.

Interesting. I see it's implemented using a SoftReference map.
I'm not aware of something similar in MRI.

If I read right, the only Regexp cache in MRI is a single last-used cache used in some String methods (match,scan,split,...).

It would be nice if we could differentiate static and dynamic regexps, but in any case I guess I could do a last-used cache as in re.c.
----------------------------------------
Feature #3388: regexp support for start_with? and end_with?
https://bugs.ruby-lang.org/issues/3388#change-32237

Author: trans (Thomas Sawyer)
Status: Feedback
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: core
Target version: 2.0.0


=begin
 ruby-1.9.2-head > "aBcdeFghIj".start_with?(/abc/i)
 => false 
 
 In my implementation of start_with? it is easy enough to utilize #index, which works fine:
 
   def start_with?(pattern)
     index(pattern) == 0
   end
 
 But #end_with? is more difficult, and I had to use regular expressions.
 
     def end_with?(suffix)
       suffix = Regexp.escape(suffix) if String===suffix
       /#{suffix}$/.match(self) ? true : false
     end
 
 However, we might get rid of the '? true : false' and return the MatchData, since that could be useful information.
=end



-- 
http://bugs.ruby-lang.org/